Asking for help with variables

2 visualizaciones (últimos 30 días)
Ivan
Ivan el 15 de Sept. de 2024
Comentada: Ivan el 16 de Sept. de 2024
1) I am developing a code and I have stored a column from a database (numerical values) inside a variable. When using the 'ones' function and utilizing the variable where I have stored the column, the code does not work. However, when I program the same function and call the column of values directly, it allows me to run the code. Is there any way to use the name of the variable that I created?
n_inter = length(data_inter.RSN); % Utilizado para regresion
n_intra = length(data_intra.RSN); % Utilizado para regresion
x_axis = PGA1100_inter; % variable seleccionada para eje x
X_inter = [ones(n_inter,1) data_inter.PGA1100]; %(allows me)
X_intra = [ones(n_intra,1) x_axis]; %(does not allow)
2) Also, I would like to know if it is possible to store the following code inside a table, meaning that the workspace looks much cleaner and all the generated variables are stored inside a table.
% Interplaca
[b_inter_PGA] = regress(data_inter.res_PGA, X_inter);
[b_inter_PGV] = regress(data_inter.res_PGV, X_inter);
[b_inter_002] = regress(data_inter.res_002, X_inter);
[b_inter_015] = regress(data_inter.res_015, X_inter);
[b_inter_02] = regress(data_inter.res_02, X_inter);
[b_inter_03] = regress(data_inter.res_03, X_inter);
[b_inter_1] = regress(data_inter.res_1, X_inter);
[b_inter_3] = regress(data_inter.res_3, X_inter);
  1 comentario
Walter Roberson
Walter Roberson el 16 de Sept. de 2024
We can speculate that:
  • perhaps length(data_inter.PGA1100) is not the same as length(PGA1100_inter)
  • perhaps PGA1100_inter is a row vector but data_inter.PGA1100 is a column vector
  • perhaps PGA1100_inter is a column vector but data_inter.PGA1100 is a row vector

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 16 de Sept. de 2024
% Interplaca
T = table();
T.b_inter_PGA = regress(data_inter.res_PGA, X_inter);
T.b_inter_PGV = regress(data_inter.res_PGV, X_inter);
T.b_inter_002 = regress(data_inter.res_002, X_inter);
T.b_inter_015 = regress(data_inter.res_015, X_inter);
T.b_inter_02 = regress(data_inter.res_02, X_inter);
T.b_inter_03 = regress(data_inter.res_03, X_inter);
T.b_inter_1 = regress(data_inter.res_1, X_inter);
T.b_inter_3 = regress(data_inter.res_3, X_inter);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by