Solving 1 equation with 1 unknown

1 回表示 (過去 30 日間)
Cizzxr
Cizzxr 2021 年 3 月 19 日
回答済み: David Hill 2021 年 3 月 19 日
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

回答 (1 件)

David Hill
David Hill 2021 年 3 月 19 日
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);

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by