matrix dimension mismatch problem
3 views (last 30 days)
Show older comments
hiii
i have an issue of matrix dimension mismatch..i have this following code.
R=1:1:500;
d=[1 2 3 4];
delB=1;
Bmn=1;
a=1+((delB*d)-(Bmn*d./Rb)).^2;
b=1+(delB*d).^2-(Bmn*d./Rb).^2;
c=1+((delB*d)+(Bmn*d./Rb)).^2;
hmn=1.414*kpqt^2*d*((1./(sqrt(a.*(b+sqrt(a.*c)))))+(1./(sqrt(c.*(b+sqrt(a.*c))))));
XT=tanh(hmn*L);
This is showing matrix dimention mismatch.
plz help me out..
thank u in advance.
0 Comments
Answers (2)
Star Strider
on 27 Jun 2020
The assignment to ‘Rb’ appears to be missing. Since you are using element-wise division wih it, it appears to be a vector, so I created it as a random (1x4) vector to match ‘d’. (Also, ‘kpqt’ and ‘L’ are missing, although they appear to be a scalars.)
Assuming that ‘Rb’ is also a (1x4) vector, do element-wise multiplication:
hmn=1.414*kpqt^2*d.*((1./(sqrt(a.*(b+sqrt(a.*c)))))+(1./(sqrt(c.*(b+sqrt(a.*c))))));
↑ ← HERE
If the undefined variables have different row and column sizes than I assumed here, my Answer may need to change.
2 Comments
Star Strider
on 27 Jun 2020
My pleasure!
In that situation, you also need to transpose either ‘d’ or ‘R’ (although not both).
My original Answer remains valid with those changes, since that multiplication needs to be element-wise either way.
.
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!