What's wrong in my simple for cycle code?

Hello everyone,
I load an input table as column vectors with the parameters I need to solve some equations (picture 1).
I implement a for cycle that it does not work properly. This is the code
clear; clc; close;
load('data')
k = [ID_STOP];
for i = 1:numel(k)
s = exp((GSI-100)/(9-3*D));
mb = mi.*exp((GSI-100)/(28-14*D));
a = 0.5 + ((exp(-GSI/15)-exp(-20/3))/6);
o3max = ocm.*0.72.*(ocm./w.*H).^-0.91 ;
o3n = o3max./oci;
friction_angle = asind((6.*a.*mb.*((s + mb.*o3n).^(a - 1)))/(2.*(1+a).*(2+a)+(6.*a.*mb.*((s + mb.*o3n).^(a - 1)))))
cohesion = 10^3*((oci.*(s.*(1+2.*a)+mb.*o3n.*(1-a))*((s + mb.*o3n).^(a - 1))) / ((1+a).*(2+a)*sqrt(1+(6.*a.*mb.*((s + mb.*o3n).^(a - 1))/(1+a).*(2+a)))))
results(i,:) =[friction_angle cohesion]
end
When I run the code (don't care about the %), "friction angle" is a vector of 110x110 NaN values. "cohesion" equation instead give me the error
"Error using /
Matrix dimensions must agree."
The results I would like to obtain are 110x1 vectors, one for friction angle results and the other for the cohesion results. I observe that the vector resulted from s, mb and a are 110x110. Why?
Thank everyone for the answers
Enrico

2 commentaires

Geoff Hayes
Geoff Hayes le 27 Août 2019
Enrico - can you post the code instead of a screen shot of the code? And perhaps include a small subset of the data too...
Enrico D'Addario
Enrico D'Addario le 27 Août 2019
I have uploaded the excel file and copied the code
Thank you Geoff

Connectez-vous pour commenter.

 Réponse acceptée

darova
darova le 27 Août 2019

0 votes

You forgot the dot
1Untitled.png
Also you don't need for loop since all your variables are vectors

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by