I am getting "Conversion to logical from table is not possible." error, how do you solve it?

6 ビュー (過去 30 日間)
Im developing a code that requires a function that needs to read a table from an Excel File. When I try to run it, I am getting "conversion to logical from table is not possible" for the conditional section "if M <= Mh". How can I solve this problem?
The Excel File only contains numeric coefficients.
This is the code that i'm working for.
function [Y,sf,st,stot] = GMM_Heresi_2023(T,M,z,F_in,Rrup,Rhyp,Vs30)
%%
if F_in == 0 || F_in == -888
M = min(M,9);
elseif F_in == 1 || F_in == -777
M = min(M,8);
end
%% Coeficientes Heresi pg.5
Table = readtable('Heresi_ValoresGMM.xlsx');
T2 = Table.Var1;
ind_coeff = find(T == T2(:));
c0 = Table(ind_coeff,2);
dc0 = Table(ind_coeff,3);
c1 = Table(ind_coeff,4);
dc1 = Table(ind_coeff,5);
c2 = Table(ind_coeff,6);
dc2 = Table(ind_coeff,7);
c3 = Table(ind_coeff,8);
Mh = Table(ind_coeff,9);
c4 = Table(ind_coeff,10);
dc4 = Table(ind_coeff,11);
c5 = Table(ind_coeff,12);
c6 = Table(ind_coeff,13);
c7 = Table(ind_coeff,14);
%% F_event term
if M <= Mh
f_event = c0 + dc0*F_in + (c1 + dc1*F_in)*(M - Mh) + c3*(z - 60)*F_in;
elseif M >= Mh
f_event = c0 + dc0*F_in + (c2 + dc2*F_in)*(M - Mh) + c3*(z - 60)*F_in;
end
%% F_path term
if F_in == 0 || F_in == -888 && M >= 7.7
R = Rrup;
else
R = Rhyp;
end
f_path = (c4 + dc4*F_in + c5*(M - 5))*ln(R) + c6*R;
%% f_soil term
f_soil = c7*ln(Vs30/600);
%% PGA or PSA and standar deviations
Y = e^(f_event + f_path + f_soil);
st = Tabla(ind_coeff,15);
sf = Tabla(ind_coeff,16);
stot = sqrt(sf^2 + st^2);

採用された回答

Stephen23
Stephen23 2024 年 7 月 29 日
"How can I solve this problem?"
Use the correct indexing:
c0 = Table(ind_coeff,2); % what you are doing: return another table
c0 = Table{ind_coeff,2}; % what you should be doing: return the table **content**
  1 件のコメント
Ivan
Ivan 2024 年 7 月 29 日
Thank you very much, Im getting used to this software. It worked.

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by