<< I am trying to continue the square wave below for a project and I got my code to get the first 2 peaks as seen below, but I cannot seem to make it continue in my for loop. I just want it to continue till some defined distance X. Any help would be great. Thank you all for the help.
<<
>>
>>

回答 (1 件)

Star Strider
Star Strider 2018 年 3 月 15 日

0 投票

I can barely read your code and I can’t run the image you posted.
That aside, the repmat (link) function could be useful.

2 件のコメント

Grant Gibson
Grant Gibson 2018 年 3 月 15 日
pattern = [ ND No LH 0; No No LH 1; No y LH 1; No+ND y LH 1; No+ND No LH 1; No+2*ND No LH 1];
for N = 1:(length(x)) % Define in a way to have it change when numbers changed r = No*N; pattern_new = [ No+r No LH 1; No+r y LH 1; No+ND+r y LH 1; No+ND+r No LH 1; No+2*ND+r No LH 1]; infill = [pattern;pattern_new] for count = length(x):1 R = No*count; Pattern_new = [ No+R+r No LH 1; No+r+R y LH 1; No+ND+r+R y LH 1; No+ND+r+R No LH 1; No+2*ND+r+R No LH 1]; New_Infill = [infill;Pattern_new] end
end
Sorry the image wont run, but here is the code I am trying to make work.
Star Strider
Star Strider 2018 年 3 月 15 日
Lacking the values for the constants.
I intended something like this:
v = [0 0 1 1 1 1 0 0];
t = 0:numel(v)-1;
vr = repmat(v, 1, 10);
tr = 0:numel(vr)-1;
figure(1)
subplot(2,1,1)
plot(t, v)
axis([xlim -0.1 1.1])
subplot(2,1,2)
plot(tr, vr)
axis([xlim -0.1 1.1])
Substitute ‘pattern’ for ‘v’.

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

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

タグ

質問済み:

2018 年 3 月 15 日

コメント済み:

2018 年 3 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by