Hello. Im currently creating a code in Matlab and I am running into this error that I will attach in a screenshot. I am new to Matlab so I am having trouble fixing it.
조회 수: 1 (최근 30일)
이전 댓글 표시
clear all
clc
t=0:0.01:5;
h=12.0 * exp(-2.0*t).*(t>= 0);
x=5* (t >= 0)-5* (t >=1.0);
y=conv(x,h,'full')*0.01;
figure;
subplot(3,1,1);
plot(t,h,'r','Linewidth',2);
title('Impulse Response h(t)');
xlabel('time (s)');
ylabel('amplitude');
subplot(3,1,2);
plot(t,x,'b','Linewidth',2);
title('input signal x(t)');
xlabel('time (s)');
ylabel('amplitude');
subplot(3,1,3);
plot(t(1:length(y)),y,'g','Linewidth',2);
title('Analytical System Response y(t)');
xlabel('time (s)');
ylabel('amplitude');
댓글 수: 3
John D'Errico
2024년 2월 7일
편집: John D'Errico
2024년 2월 7일
When you attach a picture of code, you make it far more difficult for someone to help you, since we are forced to retype your code completely.
What is worse, if you don't even show the error you got! Can we read your mind? I'm tryign, but the MATLAB crystal ball is foggy today.
Is there a good reason why you want to make it more difficult to get help, since it is trivial to paste in the text itself?
When you do give us the text, also paste in the COMPLETE ERROR MESSAGE. So EVERYTHING in red.
답변 (2개)
Walter Roberson
2024년 2월 7일
y=conv(x,h,'full')*0.01;
The length of a 'full' convolution is longer than than the individual inputs: it is (length(First) + length(Second) - 1)
plot(t(1:length(y)),y,'g','Linewidth',2);
You use the length of the full convolution to index something that is the length of the original signal.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!