ERROR for Matrix dimensions must agree.

조회 수: 1 (최근 30일)
Coleman
Coleman 2016년 2월 23일
댓글: Coleman 2016년 2월 23일
Hello all,
here is my function
function [error] =stress5_function(Ke,n,Sult,u,t,S0,k,m)
pa=0.1013 ;
S3=5 ;
Ei=Ke.*pa.*(S3./pa).^n;
Rf=(S0+k.*exp(-(S3./m)))./(Sult+u.*exp(-(S3./t)));
% z=(σ1-σ3)
z=0:0.0001:5;
Et=Ei.*(1-(Rf.*z)./(S0+k.*exp(-(S3./m))));
Et(Et<0)=0;
x=(z./Et).*100;
A=xlsread('5MPa','A1:A32');
B=A';
C=xlsread('5MPa','B1:B32');
D=C';
startingIndex = find(x==0);
endingIndex = find(x>=16);
desiredX = x(startingIndex:endingIndex);
desiredZ = z(startingIndex:endingIndex);
A1 = trapz(desiredX,desiredZ);
A2= trapz(B,D);
err= ((A1-A2)./A1)*100;
display(err,'error %');
end
when I type stress5_function([1115 1116],[0.3 0.4], [2.7 2.8], [22 23],[1.11 1.8],[2.677 4.462],[30.9 50],[0.97 1.5]) the error occur.
I can do the function with a set of parameter but can't do it with two
Matrix dimensions must agree.
Error in stress5_function (line 9)
Et=Ei.*(1-(Rf.*z)./(S0+k.*exp(-(S3./m))));
Can anyone please help !!! Thanks a lot!!!!

채택된 답변

Robert
Robert 2016년 2월 23일
Your variable z is not the same size as Rf, which matches the size of your inputs. The element-wise multiplication is happy to expand your scalars when you multiply by z but cannot do the same when you input vectors.
  댓글 수: 1
Coleman
Coleman 2016년 2월 23일
so can you give me some suggestions to fix the problem??

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by