"Error using /. Matrix Dimensions must agree." (Tried both / and ./)

조회 수: 3 (최근 30일)
Luis
Luis 2022년 11월 16일
답변: Navya Singam 2022년 11월 21일
Not sure why I am getting this error. I read through the explanation that the Matlab helper gives you, but I am still confused. Here is my code so far:
>> d31=-320e-12;
>> Yp=62e9;
>> Yfca=250e9;
>> vp=0.5;
>>a=linspace(0,1);
>> d31eff=-d31./(log(1-a)*((1/a)-0.5))
Error using /
Matrix dimensions must agree.
I am very new to Matlab so any additional details are welcomed. Thank you!
  댓글 수: 2
Stephen23
Stephen23 2022년 11월 16일
a has 100 elements. What do you expect 1/a to return? You need:
1./a
Torsten
Torsten 2022년 11월 16일
d31eff = -d31 ./ ( log(1-a) .* (1./a - 0.5) )
instead of
d31eff=-d31./(log(1-a)*((1/a)-0.5))

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

답변 (1개)

Navya Singam
Navya Singam 2022년 11월 21일
Hi Luis,
Changing this line of code wil resolve the issue.
d31eff=-d31./(log(1-a)*((1/a)-0.5))
to
d31eff=-d31./(log(1-a).*((1./a)-0.5));
You can refer to the following documenatations to understand more on the array operations and rdivide.

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by