Filter löschen
Filter löschen

title plot can't be shown + grid

1 Ansicht (letzte 30 Tage)
Faisal Al-Wazir
Faisal Al-Wazir am 28 Okt. 2022
Beantwortet: Star Strider am 28 Okt. 2022
i'm trying to plot unit step function but i can't use the title function and grid for some reason
clc
clear
u = @(t) double(t>=0);
h = @(t) u(t+1)*(t+1)-u(t)*(3/2)*(t)+u(t-2)*0.5*(t-2);
p= @(t) h(2*t)
p = function_handle with value:
@(t)h(2*t)
p1= @(t) h(0.5*t)
p1 = function_handle with value:
@(t)h(0.5*t)
p2= @(t) h(t-1)
p2 = function_handle with value:
@(t)h(t-1)
p3= @(t) h(2-t*0.5)
p3 = function_handle with value:
@(t)h(2-t*0.5)
subplot(2,3,1)
grid on
title('x')
fplot(h,[-5,5])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
ylim([-2 4])
subplot(2,3,1)
fplot(h,[-5,5])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
ylim([-2 4])
subplot(2,3,2)
title('x')
fplot(p,[-5,5])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
ylim([-2 4])
subplot(2,3,3)
title('x')
fplot(p1,[-5,5])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
ylim([-2 4])
subplot(2,3,4)
title('x')
fplot(p2,[-5,5])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
ylim([-2 4])
subplot(2,3,5)
title('x')
fplot(p3,[-5,5])
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
ylim([-2 4])

Akzeptierte Antwort

Star Strider
Star Strider am 28 Okt. 2022
The title and grid functions do not apply until the axes are created. Also, there are two ‘subplot(2,3,1)’ creations, the second overwrites the first. (I added the subplot numbers to the title calls for clarity. Edit those out those later.)
Try this —
% clc
% clear
u = @(t) double(t>=0);
h = @(t) u(t+1).*(t+1)-u(t).*(3/2).*(t)+u(t-2).*0.5.*(t-2);
p= @(t) h(2*t);
p1= @(t) h(0.5*t);
p2= @(t) h(t-1);
p3= @(t) h(2-t*0.5);
figure
subplot(2,3,1)
fplot(h,[-5,5])
grid
title('x 231')
ylim([-2 4])
% subplot(2,3,1)
% fplot(h,[-5,5])
% ylim([-2 4])
subplot(2,3,2)
fplot(p,[-5,5])
title('x 232')
ylim([-2 4])
subplot(2,3,3)
fplot(p1,[-5,5])
title('x 233')
ylim([-2 4])
subplot(2,3,4)
fplot(p2,[-5,5])
title('x 234')
ylim([-2 4])
subplot(2,3,5)
fplot(p3,[-5,5])
title('x 235')
ylim([-2 4])
.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots 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!

Translated by