how to make my graph in center without moving it or dragging it to the center
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
fprintf('Please choose any type of signal below.\n1. Impulse\n2. Step function\n3. DC Source\n4. Signum function\n5. Rising exponent function\n6. Cosine function\n7. Sine function\n8. Square function\n9. Triangular function\n10. Symmetrical decaying exponent function')
s=input('\nSignal number: ');
a=input('Please choose any of these signal transformation\n1. Time scale\n2. Time shift\n3. Time inversion\n4. Amplitude scale\n5. Amplitude Shift\n6. Amplitude inversion\n');
switch (s)
case 7
A=input('Enter Amplitude:');
F= input('Enter frequency:');
t=0:0.01:4;
y= A*sin(2*pi*F*t);
plot(t,y,'b')
title ('Sine Wave')
xlabel ('Time')
ylabel('Amplitude')
grid on
hold on
switch (a)
case 1 %time scale
z= input('Enter time scale value:');
y= A*sin(2*pi*F*t);
plot((z\t),y,'k')
grid on
hold off
case 2 %time shifting
z= input('Enter time shifting value:');
y= A*sin(2*pi*F*t);
plot((t-z),y,'k')
grid on
hold off
case 3 %time inversion
y= A*sin(2*pi*F*(-t));
plot(t,y,'g')
grid on
hold off
case 4 %amplitude scale
z=input('Enter amplitude scale value:');
y= z*(A*sin(2*pi*F*t));
plot(t,y,'k');
grid on
hold off
case 5 %amplitude shift
z=input('Enter amplitude shift value:');
y= (A*sin(2*pi*F*t))-z;
plot(t,y,'k');
grid on
hold off
case 6 %amplitude inversion
y= -A*sin(2*pi*F*t);
plot(t,y,'k')
grid on
hold off
end
instead of this graph,
i want the graph to be like this automatically
0 comentarios
Respuesta aceptada
DGM
el 22 de En. de 2022
Editada: DGM
el 22 de En. de 2022
There's no need for all this code repetition. The cases should not be nested. Create the unmodified vectors, create the modified copies, then plot.
fprintf('Please choose any type of signal below.\n1. Impulse\n2. Step function\n3. DC Source\n4. Signum function\n5. Rising exponent function\n6. Cosine function\n7. Sine function\n8. Square function\n9. Triangular function\n10. Symmetrical decaying exponent function')
s = input('\nSignal number: ');
a = input('Please choose any of these signal transformation\n1. Time scale\n2. Time shift\n3. Time inversion\n4. Amplitude scale\n5. Amplitude Shift\n6. Amplitude inversion\n');
switch (s)
% ... other cases
case 7
A = input('Enter Amplitude: '); % trailing space for clarity
F = input('Enter frequency: ');
t = 0:0.01:4;
y = A*sin(2*pi*F*t);
figtitle = 'Sine Wave'; % for later
% ... other cases
end
switch (a)
% ... other cases
case 2 %time shifting
z = input('Enter time shifting value: ');
tmod = t-z;
ymod = y;
% ... other cases
case 4 %amplitude scale
z = input('Enter amplitude scale value: ');
tmod = t;
ymod = z*y;
% ... other cases
end
% do the plotting last
plot(t,y,'b')
hold on
plot(tmod,ymod,'k')
hold off
title(figtitle)
xlabel('Time')
ylabel('Amplitude')
grid on
% adjust limits to create padding
xlim(xlim + [-1 1]*range(xlim)*0.2)
ylim(ylim + [-1 1]*range(ylim)*0.2)
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Import and Network Parameters en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!