Plotting the following equation L=((N^2)*m​uo*Ag1)/(x​+((g*R)/(2​*h)))

I am new to matlab and need help plotting the following equation L=((N^2)*muo*Ag1)/(x+((g*R)/(2*h))) against x where x varies from xmin to xmax in steps of 0.0001m.
My parameters are as follows: R=0.065; h=0.0319; g=0.00055; xmin=0.0011; xmax=0.0187; N=2470; muo=4*pi*1e-7; Ag1=pi*R^2;
I have tried the following code with no luck: x=[xmin:0.0011:xmax] plot=(x*1000,L);xlabel=('position x (mm)'); x is multiplied by 1000 here to get value of x in mm rather than in m which are used in the equations.
Any help appreciated.
Regards
Mark

 Accepted Answer

Your code works except for your not vectorising the division (replace ‘/’ with ‘./’) in the ‘L’ calculation:
L=((N^2)*muo*Ag1)./(x+((g*R)/(2*h)));

More Answers (1)

Many thanks for pointing out where I was going wrong.

1 Comment

As always, my pleasure.
You weren’t ‘going wrong’. Forgetting to vectorise the division seems to be a frequent problem. I’ve seen it several times in the last few days.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!