Step input applied for different seconds
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천

I want to apply step input to the system as in the graphs above, where the second values are seen in the row and column. Entries will start at 1 second and end at 5 and 40 seconds respectively. I want to plot the vibration graph x(t), and the amplitude graph of these vibrations, but I couldn't find where to start.
채택된 답변
Star Strider
2022년 12월 21일
Experiment with this approach —
N = 1500; % Desired Length Of Simulation
t = linspace(0, 50, N);
u = @(tlen,lz) [zeros(1,lz) 10*ones(1,size(t(t<=tlen),2)-lz) zeros(1,size(t(t>tlen),2))]; % 'tlen'=Length Of '10' Region, 'lz'=Length Of Leading Zero Vector
u5 = u(5,2);
u40 = u(40,2);
figure
subplot(2,1,1)
plot(t, u5, 'g', 'LineWidth',1.5)
grid
title('u(5,2)')
axis('padded')
ylim([0 15])
subplot(2,1,2)
plot(t, u40, 'b', 'LineWidth',1.5)
grid
title('u(40,2)')
axis('padded')
ylim([0 15])

Use ‘t’ and ‘u(tlen,lz)’ as inputs to lsim to get the system response. Change ‘u(tlen,lz)’ to get the result you want.
.
댓글 수: 10
Thank you for the answer actually I have these graphs but I want to plot the vibration graph x(t), and the amplitude graph of these vibrations.
My pleasure!
Use them as inputs to the lsim function, as I mentioned previously. See the documentation I linked to for that.
Example —
N = 1500; % Desired Length Of Simulation
t = linspace(0, 50, N);
u = @(tlen,lz) [zeros(1,lz) 10*ones(1,size(t(t<=tlen),2)-lz) zeros(1,size(t(t>tlen),2))]; % 'tlen'=Length Of '10' Region, 'lz'=Length Of Leading Zero Vector
sys = tf(3,[1 2 3]) % From The 'lsim' Documentation
sys =
3
-------------
s^2 + 2 s + 3
Continuous-time transfer function.
figure
subplot(2,1,1)
lsim(sys, u(5,2), t)
grid on
subplot(2,1,2)
lsim(sys, u(40,2), t)
grid on

Use my code here, with your system.
.
I got it thank you.
Star Strider
2022년 12월 21일
As always, my pleasure!
Mustafa Furkan
2022년 12월 25일
편집: Mustafa Furkan
2022년 12월 25일
@Star Strider hi again,
If I want to use the step function instead of the lsim function, how can I do that? I plot the step charts in this way by making very minor changes in the formula you wrote.

Is it possible to get step response using only this graph? (Thanks to the step function, the oscillation after the step can also be observed.)
The step function itself cannot do what you want. The best you can do is to cobble together (i.e. concatenate) outputs from different step calls and plot them together —
systf = @(id) tf(3,[1 2 3], 'InputDelay',id); % From The 'lsim' Documentation, Adding 'InputDelay' As A Variable Argument To The Anonymous Function Implementation
N = 1500; % Desired Length Of Simulation
t = linspace(0, 50, N);
t0 = t(t<=5);
t5 = t(t>5);
opts = stepDataOptions;
opts.InputOffset = 0;
opts.StepAmplitude = 10;
[y{1},tout{1},x{1}] = step(systf(0),t0,opts);
opts.InputOffset = y{1}(end);
opts.StepAmplitude = -y{1}(end);
[y{2},tout{2},x{2}] = step(systf(5),t5,opts);
figure
plot(tout{1}, y{1})
hold on
plot(tout{2}, y{2})
hold off
grid

figure
subplot(2,1,1)
plot(tout{1}, y{1})
grid
axis([0 50 -2 12])
subplot(2,1,2)
plot(tout{2}, y{2})
grid
axis([0 50 -2 12])

t0 = t(t<=40);
t40 = t(t>40);
opts = stepDataOptions;
opts.InputOffset = 0;
opts.StepAmplitude = 10;
[y{1},tout{1},x{1}] = step(systf(0),t0,opts);
opts.InputOffset = y{1}(end);
opts.StepAmplitude = -y{1}(end);
[y{2},tout{2},x{2}] = step(systf(40),t40,opts);
figure
plot(tout{1}, y{1})
hold on
plot(tout{2}, y{2})
hold off
grid

figure
subplot(2,1,1)
plot(tout{1}, y{1})
grid
axis([0 50 -2 12])
subplot(2,1,2)
plot(tout{2}, y{2})
grid
axis([0 50 -2 12])

Combining 'InputDelay' with the system object ‘systf’ (making that an anonymous function for convenience) and the step options structure stepDataOptions together makes this work. (I learned something about both functions in the process.)
It would be possible to use a for loop for this, and with more such simulations that would be an option, however with only two iterations, it didn’t seem worth the effort.
.
Unable to perform assignment because brace indexing is not supported for
variables of this type.
Error in deneme22 (line 11)
[y{1},tout{1},x{1}] = step(systf(0),t0,opts);
Star Strider
2022년 12월 25일
As always,. my pleasure!
It runs without error for me.
The most likely problem is that you defined one of those variables as something other than a cell array earlier in your code. Since I have no idea what that could be, rename those outputs to something else that does not confilct with already existing variables, for example:
[ys{1},touts{1},xs{1}] = step(systf(0),t0,opts);
or something else appropriate. Do that for all the step calls.
You will need to change the variable names, since I have no idea what the precise problem is, only what I believe could be causing it. Any valid MATLAB variable names will work.
.
It worked now thank you. Unfortunately, as you said, I don't get a different result than before. I guess I'll have to include values like mass stiffness to get a result as expected.
Star Strider
2022년 12월 25일
As always, my pleasure!
I have no idea what results are expected. It would appear that you would be using a state space realisation. There are likely documentation examples that could help code your system.
If necessary, you can use stepinfo with the arguments of all the step calls to get that information from each of them.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Plot Customization에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
