how to shift a step-plot(input)

1 visualización (últimos 30 días)
bob de vrij
bob de vrij el 4 de Mzo. de 2016
Respondida: bob de vrij el 5 de Mzo. de 2016
Hello. I am struggeling with Matlab. My knowledge about it, is very limited. Let me introduce myself. My name is Bob,this year i am following a course digital control and this is the first year that i am confronted with Matlab. I want to shift only the step-plot(grey line) 0,25 seconds to the left so that the step wil begin at zero in stead of 0,25seconds. For clarity, the vertical part of the grey line must begin at zero in stead of 0,25sec. First i tried to subtract 0,25 from tsample in line 17--->"plot(tsample-0,25,input,'b')" But that does not work. Then I tried something with "circshift" but without result. I think it must be done in line 17 or before it. In the appendix you can find the .m file and .mat file to run the plot.(you can ignore the bode-plot). So how can i shift the grey input-line(step) with 0,25seconds to the the left?? Thank you in advance.

Respuesta aceptada

Image Analyst
Image Analyst el 4 de Mzo. de 2016
Bob, don't use input for the name of your "y" variable because it's the name of a build in function. To shift the y values to the left or right, you should generate a new y array and then plot it. Try something like this:
x = 0 : 40;
y = GetY(x); % Get original y
% Plot original y
plot(x, y, 'b*-', 'LineWidth', 2);
grid on;
hold on;
% Get a new y for a shifted x
% Pass in x that has a number subtracted from it.
y2 = GetY(x-10);
% Plot new, shifted y
plot(x, y2, 'rd-', 'LineWidth', 2);
function y = GetY(x)
y = x > 20; % Step function

Más respuestas (1)

bob de vrij
bob de vrij el 5 de Mzo. de 2016
Thank you image analyst for the quick response. I will make an attempt in the evening.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by