matrix dimension mismatch problem

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.

Answers (2)

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

thanx for responding.actually i wrote Rb to be R by mistake.R and Rb both are same.
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.
.

Sign in to comment.

Categories

Asked:

on 27 Jun 2020

Commented:

on 27 Jun 2020

Community Treasure Hunt

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

Start Hunting!