Hi,
I have a function that I am not able to isolate by hand
2.31525+0.231525*sin(2*pi*x)-(1+.2*m.^2).^3/m
where x runs from 0 to 1.
I was able to plot this using fimplicit, but now I want to plot another function that uses these same m values as an input. What is the easiest way to do this?
I am new to matlab and only used one line of code:
fimplicit(@(x,m)2.31525+0.231525*sin(2*pi*x)-(1+.2*m.^2).^3/m,[0 1])
thanks!

1 件のコメント

Michael P. Cohen
Michael P. Cohen 2021 年 2 月 18 日
to be specific, I am looking to plot:
t = 315/(1+.2m.^2) and p = (1.186/((1+.2m.^2).^-3.5)) each as a function of x

サインインしてコメントする。

 採用された回答

David Hill
David Hill 2021 年 2 月 18 日

0 投票

function out = eqn(x)
b=@(m)2.31525+0.231525*sin(2*pi*x)-(1+.2*m.^2).^3/m;
out=fsolve(b,.5);
end
x=0:.01:1;
y=zeros(size(x));
for k=1:length(x)
y(k)=eqn(x(k));
end
plot(x,y);

4 件のコメント

Michael P. Cohen
Michael P. Cohen 2021 年 2 月 18 日
Thank you for the answer! This code is still getting an error at the line x=0:.01:1; and I am not sure why
Walter Roberson
Walter Roberson 2021 年 2 月 18 日
If you put both in the same file then the function needs to be after the script.
Michael P. Cohen
Michael P. Cohen 2021 年 2 月 18 日
Thanks Walter
David Hill
David Hill 2021 年 2 月 18 日
function out = eqn(x)
b=@(m)2.31525+0.231525*sin(2*pi*x)-(1+.2*m.^2).^3/m;
out=fsolve(b,.5);
end
Establish function, then run script:
x=0:.01:1;
y=zeros(size(x));
for k=1:length(x)
y(k)=eqn(x(k));
end
t =@(m) 315./(1+.2*m.^2);
p =@(m) (1.186./((1+.2*m.^2).^-3.5));
subplot(3,1,1);
plot(x,y);
subplot(3,1,2);
plot(x,t(y));
subplot(3,1,3);
plot(x,p(y));

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by