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!