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

10 visualizaciones (últimos 30 días)
Ivan el 29 de Jul. de 2024
Comentada: Ivan el 29 de Jul. de 2024
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
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);
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

Stephen23 el 29 de Jul. de 2024
"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 comentarioMostrar -1 comentarios más antiguosOcultar -1 comentarios más antiguos
Ivan el 29 de Jul. de 2024
Thank you very much, Im getting used to this software. It worked.

Iniciar sesión para comentar.

### Categorías

Más información sobre Data Import from MATLAB en Help Center y File Exchange.

R2023a

### Community Treasure Hunt

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

Start Hunting!

Translated by