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 件のコメント

Geoff Hayes
Geoff Hayes 2019 年 8 月 27 日
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 2019 年 8 月 27 日
I have uploaded the excel file and copied the code
Thank you Geoff

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

 採用された回答

darova
darova 2019 年 8 月 27 日

0 投票

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

1 件のコメント

Enrico D'Addario
Enrico D'Addario 2019 年 8 月 28 日
Thank you very much now it works!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by