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

2 views (last 30 days)
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 Comments
Torsten
Torsten on 16 Nov 2022
d31eff = -d31 ./ ( log(1-a) .* (1./a - 0.5) )
instead of
d31eff=-d31./(log(1-a)*((1/a)-0.5))

Sign in to comment.

Answers (1)

Navya Singam
Navya Singam on 21 Nov 2022
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.

Categories

Find more on Operators and Elementary Operations in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by