I can't figure out why am not getting a plot on my code
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Write a MATLAB code for plot original and transformation function of
function y=ga(t);
y = -2*(t<=-1)+2*t.*(-1<t&t<=1)+(3-t.^2).*(1<t&t<=3)-6*(t>3);
figure;
tmin=-3;tmax=8;N=100;
dt=(tmax-tmin)/N; t=tmin+dt*[0:N]';
g0=ga(t);g1=-3*ga(4-t);
subplot(2,1,1);p=plot(t,g0,'k');set(p,'LineWidth',2);grid;
ylabel('g(t)');
title('(a)-g(t)=-2,t<-1,2t,-13')
subplot(2,1,2);p=plot(t,g1,'k');set(p,'LineWidth',2);grid;
xlabel('t');ylabel('-3g(4-t');
0 Kommentare
Antworten (1)
Chunru
am 25 Okt. 2022
If you put the script and local function ga in the same file, then local functions should be placed at the end of the files as shown below. You can also put the local function in a separate file,
figure;
tmin=-3;tmax=8;N=100;
dt=(tmax-tmin)/N; t=tmin+dt*[0:N]';
g0=ga(t);g1=-3*ga(4-t);
subplot(2,1,1);p=plot(t,g0,'k');set(p,'LineWidth',2);grid;
ylabel('g(t)');
title('(a)-g(t)=-2,t<-1,2t,-13')
subplot(2,1,2);p=plot(t,g1,'k');set(p,'LineWidth',2);grid;
xlabel('t');ylabel('-3g(4-t');
function y=ga(t);
y = -2*(t<=-1)+2*t.*(-1<t&t<=1)+(3-t.^2).*(1<t&t<=3)-6*(t>3);
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Manage Products finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!