An integer multiple a function

6 ビュー (過去 30 日間)
Tu Nguyen
Tu Nguyen 2022 年 2 月 15 日
コメント済み: Tu Nguyen 2022 年 2 月 15 日
I want the code run with 5 different graph on loop. But the result is just one. Can anyone help me please?
load ecg_hw2.mat;
n = [4:0.01:4];
N = [2 4 8 16 32];
b = 1./N;
ye = cell(size(b));
t = 1/200;
T2 = 0:t:1000;
h = dirac(n);
idx = h == Inf;
h(idx) = 1;
for i = numel(b);
ye{i} = b(i)*(conv(ecg,h));
figure (4);
subplot(6,1,i);
plot(ye{i});
end
  1 件のコメント
Tu Nguyen
Tu Nguyen 2022 年 2 月 15 日
I forgot the value of n, just updated

サインインしてコメントする。

採用された回答

DGM
DGM 2022 年 2 月 15 日
n isn't defined. I'm assuming that's T2?
load ecg_hw2.mat;
N = [2 4 8 16 32];
b = 1./N;
ye = cell(size(b));
t = 1/200;
T2 = 0:t:1000;
h = dirac(T2);
idx = h == Inf;
h(idx) = 1;
for i = 1:numel(b)
ye{i} = b(i)*(conv(ecg,h));
%figure(4);
subplot(5,1,i);
plot(ye{i});
end
  1 件のコメント
Tu Nguyen
Tu Nguyen 2022 年 2 月 15 日
My code is exactly like you, but my result just show up 1 graph. I dont know why, can you hep me plese?

サインインしてコメントする。

その他の回答 (1 件)

Arif Hoq
Arif Hoq 2022 年 2 月 15 日
編集済み: Arif Hoq 2022 年 2 月 15 日
I dont know the value of n. I took it 200.
A=load('ecg_hw2.mat');
ecg=A.ecg ;
N = [2 4 8 16 32];
b = 1./N;
ye = cell(size(b));
t = 1/200;
T2 = 0:t:1000;
n = [4:0.01:4];
h = dirac(n);
idx = h == Inf;
h(idx) = 1;
for i = 1:numel(b);
ye{i} = b(i)*(conv(ecg,h));
figure (4);
subplot(3,2,i);
plot(ye{i})
end
  3 件のコメント
Arif Hoq
Arif Hoq 2022 年 2 月 15 日
編集済み: Arif Hoq 2022 年 2 月 15 日
in your code you forgot to start indexing from 1(look at herein your code: for i = numel(b)). that's why you are getting a single plot i guess.You need a range of indices. I have updated the code.
Tu Nguyen
Tu Nguyen 2022 年 2 月 15 日
I really appreciate you. I cant believe I forget very basic matlab

サインインしてコメントする。

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by