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 Kommentar

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

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

David Hill
David Hill am 18 Feb. 2021
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 Kommentare

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
If you put both in the same file then the function needs to be after the script.
Thanks Walter
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));

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by