Asking for help with variables

2 ビュー (過去 30 日間)
Ivan
Ivan 2024 年 9 月 15 日
コメント済み: Ivan 2024 年 9 月 16 日
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 件のコメント
Walter Roberson
Walter Roberson 2024 年 9 月 16 日
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

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2024 年 9 月 16 日
% 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);
  1 件のコメント
Ivan
Ivan 2024 年 9 月 16 日
Thanks a lot, it worked

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by