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 个评论

Enrico - can you post the code instead of a screen shot of the code? And perhaps include a small subset of the data too...
I have uploaded the excel file and copied the code
Thank you Geoff

请先登录,再进行评论。

 采纳的回答

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

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by