Clear Filters
Clear Filters

Solving 1 equation with 1 unknown

1 view (last 30 days)
Cizzxr
Cizzxr on 19 Mar 2021
Answered: David Hill on 19 Mar 2021
Hi, so i have a 11 values
[-0.5,-0.4,-0.3,-0.2,-0.1,0,0.1,0.2,0.3,0.4,0.5]
or -0.5:0.1:0.5
Lets assign these to a variable 'a'
I then have an equation which is as follows;
(125./216)*((1+0.2*((M).^2)).^3)*1./M
I want to simply make 'a' = to this equation for each value of 'a' and solve for M at each 'a' value.
I then want to plot a graph of my the values 'a' against M.
The equation ive used is as follows where the y is equal to 1.4, but ive already simplified this above. Could you please check i have simplified it correct into matlab as i feel it may be wrong

Answers (1)

David Hill
David Hill on 19 Mar 2021
a=-0.5:0.1:0.5;
for k=1:length(a)
eqn=@(M)(125/216)*((1+0.2*(M.^2)).^3)./M-a(k);
sol(k)=fzero(eqn,1);
end
plot(a,sol);

Tags

Community Treasure Hunt

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

Start Hunting!