From: Peter Zaw on
Recently one of my assignment need to run on matlab and got mrdivide error. I don't know what causes this error. So please someone help me to solve this problem. Here is my coding:

bw =20000;
r = 500;
fr = 500000;
q = fr/bw;
L = (q*r)/ (2*3.14*fr);
C = 1/L;
G = 1/r;
f =100000: 50000: 1000000;
BC =2*3.14*f*C;
BL = 1/ (2*3.14*f*C);
Y= SQRT (G^2+(BC-BL)^2);
plot (f,Y);

Error detail is here :

??? Error using ==> mrdivide
Matrix dimensions must agree.

Error in ==> ques2ans at 10
BL = 1/ (2*3.14*f*C);

>>
From: Steven_Lord on


"Peter Zaw" <peter_zaw(a)yahoo.com> wrote in message
news:i40rg8$53h$1(a)fred.mathworks.com...
> Recently one of my assignment need to run on matlab and got mrdivide
> error. I don't know what causes this error. So please someone help me to
> solve this problem. Here is my coding:
>
> bw =20000;
> r = 500;
> fr = 500000;
> q = fr/bw;
> L = (q*r)/ (2*3.14*fr);
> C = 1/L;
> G = 1/r;
> f =100000: 50000: 1000000;
> BC =2*3.14*f*C;
> BL = 1/ (2*3.14*f*C);
> Y= SQRT (G^2+(BC-BL)^2); plot (f,Y);
>
> Error detail is here :
>
> ??? Error using ==> mrdivide
> Matrix dimensions must agree.
>
> Error in ==> ques2ans at 10
> BL = 1/ (2*3.14*f*C);

Be careful when working with vectors ... the operations / and ./ are
different. The former is matrix right division (MRDIVIDE) while the latter
is elementwise right division (RDIVIDE). The latter is what I believe you
want.

The operators *, \, and ^ also have elementwise versions, so if you use
those (as you do later on in this case, on the line where you compute Y) you
should check if you need the elementwise versions.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

From: Matt J on


Presumably, you want this

BL = 1./ (2*3.14*f*C);