Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Error with matlab in following code any one know why Error using matlab.graphics

ID: 2248162 • Letter: E

Question

Error with matlab in following code any one know why

Error using matlab.graphics.chart.primitive.Line/set
Invalid parameter/value pair arguments.

>> t=[-3:0.002:5];           
y=exp(-abs(t)/4).*(ustep(t)-ustep(t-4));
figure(1);
subplot(221);fig0=plot(t,y);
set(fig0, ' Linewidth',2);
xlabel(' it t ');  
ylabel(' {f y}({it t }) ');
title(' original signal y(t) ');
t1=t*2;
y1=exp(-abs(t1)/4).*(ustep(t1)-ustep(t1-4));
figure(1);
subplot(222);fig1=plot(t,y1);
set(fig1, ' Linewidth ',2);
xlabel(' it t ');
ylabel(' {f y_1}({it t }) ');
title(' time scaling y(2t) ');
t2=t+2; % shift in time
y2=exp(-abs(t2)/4).*(ustep(t2)-ustep(t2-4));
figure(1);
subplot(223);fig2=plot(t,y2);
set(fig2, ' Linewidth ',2);
xlabel(' it t ');
ylabel(' {f y_2}({it t }) ');
title( 'time shifting y(t+2) ' );
t3=2-t*2;
y3=exp(-abs(t3)/4).*(ustep(t3)-ustep(t3-4));
figure(1);
subplot(224);fig3=plot(t,y3);
set(fig0, ' Linewidth ',2);  
xlabel(' it t ');
ylabel(' {f y_3}({it t }) ');
title('y(2-2t) ');
subplot(221); axis([-3 5 -.5 1.5]); grid;
subplot(222); axis([-3 5 -.5 1.5]); grid;
subplot(223); axis([-3 5 -.5 1.5]); grid;
subplot(224); axis([-3 5 -.5 1.5]); grid;
Error using matlab.graphics.chart.primitive.Line/set
Invalid parameter/value pair arguments.

Explanation / Answer

The mistake was giving LineWidth parameter

correct one is 'LineWidth' not ' Linewidth '

Note you need to change last set from set(fig0, 'LineWidth',2); to set(fig3, 'LineWidth',2);  

The error corrected and code is:

t=-3:0.002:5;
y=exp(-abs(t)/4).*(ustep(t)-ustep(t-4));
figure(1);
subplot(221);fig0=plot(t,y);
set(fig0, 'LineWidth',2);
xlabel(' it t ');  
ylabel(' {f y}({it t }) ');
title(' original signal y(t) ');
t1=t*2;
y1=exp(-abs(t1)/4).*(ustep(t1)-ustep(t1-4));
figure(1);
subplot(222);fig1=plot(t,y1);
set(fig1, 'LineWidth',2);
xlabel(' it t ');
ylabel(' {f y_1}({it t }) ');
title(' time scaling y(2t) ');
t2=t+2; % shift in time
y2=exp(-abs(t2)/4).*(ustep(t2)-ustep(t2-4));
figure(1);
subplot(223);fig2=plot(t,y2);
set(fig2, 'LineWidth',2);
xlabel(' it t ');
ylabel(' {f y_2}({it t }) ');
title( 'time shifting y(t+2) ' );
t3=2-t*2;
y3=exp(-abs(t3)/4).*(ustep(t3)-ustep(t3-4));
figure(1);
subplot(224);fig3=plot(t,y3);
set(fig0, 'LineWidth',2);  
xlabel(' it t ');
ylabel(' {f y_3}({it t }) ');
title('y(2-2t) ');
subplot(221); axis([-3 5 -.5 1.5]); grid;
subplot(222); axis([-3 5 -.5 1.5]); grid;
subplot(223); axis([-3 5 -.5 1.5]); grid;
subplot(224); axis([-3 5 -.5 1.5]); grid;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote