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...
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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2019년 8월 27일

댓글:

2019년 8월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by