2282_es-ES
Crear una matrizEstoy tratando de crear una matriz simple a[1] = "cadena 1"... a[10] = "cadena 10"
Estoy creando esta matriz leyendo valores de una tabla, mientras recorro con una instrucción FOR. Recibo un error con la primera referencia a a[1]. (en realidad uny j se inicializa y se incrementa correctamente.
¿Qué estoy haciendo mal? Intenté buscar ayuda, pero no encuentro lo que busco.
Gracias,Re: Crear una matrizNo necesita usar un bucle For para obtener valores de columna. Podría ser más rápido usar GET VALUES:
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">open
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"$SAMPLE_DATA\Big
Clase.jmp"
style="font-size: 10pt; font-family: "Courier New"; color: black;">)
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">/*
Dos formas de hacer referencia a una columna
son exhibidos:
style="font-size: 10pt; font-family: "Courier New"; color: green;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">The
primera forma es útil si el
el nombre de la columna tiene caracteres divertidos, como una barra oblicua
style="font-size: 10pt; font-family: "Courier New"; color: green;">*/
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">name_list
estilo="">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">columna
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"name"
style="font-size: 10pt; font-family: "Courier New"; color: black;">)
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
obtener valores
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">age_list
estilo="">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: rgb(0, 0, 221);">columna
style="font-size: 10pt; font-family: "Courier New"; color: black;">(
style="font-size: 10pt; font-family: "Courier New"; color: black;">dt
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">,
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: purple;">"age"
style="font-size: 10pt; font-family: "Courier New"; color: black;">)
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
obtener valores
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: green;">/*
Si la columna es una
nombre sencillo solo referencialo directamente */
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">sex_list
estilo="">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">:
style="font-size: 10pt; font-family: "Courier New"; color: black;">sexo
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
obtener valores
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">height_list
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">:
style="font-size: 10pt; font-family: "Courier New"; color: black;">altura
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
obtener valores
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: black;">weight_list
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">=
style="font-size: 10pt; font-family: "Courier New"; color: black;">
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">:
style="font-size: 10pt; font-family: "Courier New"; color: black;">peso
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;"><<
style="font-size: 10pt; font-family: "Courier New"; color: black;">
obtener valores
style="font-size: 10pt; font-family: "Courier New"; color: azul marino;">;
style="font-size: 10pt; font-family: "Courier New"; color: black;">
Saludos,
PedroRe: Crear una matrizgracias, eso soluciono mi problema!Re: Crear una matrizProbablemente necesite "a" para ser una lista. Intenta preceder tu código con una línea: a = {};
Luego eche un vistazo a los documentos pdf de secuencias de comandos para "Listas", "Arreglos asociativos" y Matrices (o Matrix).
Comments
There are no comments yet