Cant figure out how to get my functions to graph

1 vue (au cours des 30 derniers jours)
Marissa Guadagno
Marissa Guadagno le 24 Fév 2021
f=@(y) y.*(y-2).^2.*(y+4).^(3);
phaseLine(f,-6,4);
%% 5.
y_min=-5;
y_max=3;
f1=@(y) y.*(y.^2+4);
phaseLine(f1,y_min,y_max);
y_min=-5;
y_max=3;
f2=@(y) y.*(y.^2);
phaseLine(f2,y_min,y_max);
y_min=-5;
y_max=3;
f3=@(y) y.*(y.^2-1);
phaseLine(f3,y_min,y_max);
% Code Here
%%
% Comments:
%% 6.
f=@(a,y) y.*(y.^2-a);
bifDiag244(f,-4,6,-6,6,1);
% Code Here
%%
% Comments:
%% 7.
f=@(a,y) y.*(y-a+1);
bifDiag244(f,-5,5,-6,6,1);
% Code Here
%%
% Comments:
%% Functions
function phaseLine(dydt4,y_min,y_max)
syms y
x=solve(dydt4(y)==0,y);
x=x(imag(x)==0);
hold on
for i=1:length(x)
plot (0,x(i),".k")
end
if dydt4(x(1)-1)>0
plot ([0,5],[y_min x(1)],'red')
else
plot ([0,5],[y_min x(1)],'blue')
end
if dydt4(x(end)+1)>0
plot([0,5], [y_max x(end)],'red')
else
plot([0,5], [y_max x(end)],'blue')
end
for i=1:length(x)-1
if dydt4((x(i)+x(i+1))/2>0)
plot ([0,5],[x(i) x(i+1)],'red')
else
plot ([0,5], [x(i) x(i+1)],'blue')
end
end
end
  1 commentaire
Rik
Rik le 24 Fév 2021
This time I edited your question for you. Next time, please use the tools explained on this page to make your question more readable.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 24 Fév 2021
f=@(y) y.*(y-2).^2.*(y+4).^(3);
phaseLine(f,-6,4);
%% 5.
y_min=-5;
y_max=3;
f1=@(y) y.*(y.^2+4);
phaseLine(f1,y_min,y_max);
y_min=-5;
y_max=3;
f2=@(y) y.*(y.^2);
phaseLine(f2,y_min,y_max);
y_min=-5;
y_max=3;
f3=@(y) y.*(y.^2-1);
phaseLine(f3,y_min,y_max);
% Code Here
%%
% Comments:
%% 6.
f=@(a,y) y.*(y.^2-a);
bifDiag244(f,-4,6,-6,6,1);
Unrecognized function or variable 'bifDiag244'.
% Code Here
%%
% Comments:
%% 7.
f=@(a,y) y.*(y-a+1);
bifDiag244(f,-5,5,-6,6,1);
% Code Here
%%
% Comments:
%% Functions
function phaseLine(dydt4,y_min,y_max)
syms y
x=solve(dydt4(y)==0,y);
x=x(imag(x)==0);
hold on
for i=1:length(x)
plot (0,x(i),".k")
end
if dydt4(x(1)-1)>0
plot ([0,5],[y_min x(1)],'red')
else
plot ([0,5],[y_min x(1)],'blue')
end
if dydt4(x(end)+1)>0
plot([0,5], [y_max x(end)],'red')
else
plot([0,5], [y_max x(end)],'blue')
end
for i=1:length(x)-1
if dydt4((x(i)+x(i+1))/2)>0 %FIXED
plot ([0,5],[x(i) x(i+1)],'red')
else
plot ([0,5], [x(i) x(i+1)],'blue')
end
end
end

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by