hi, i want to create a biphasic rectangular signal with amplitude of 1, duty cycle of 25%, frequency of 3Hz, is there a matlab function for this?
i can easily make the rectangular train pulse but im struggling with this
it should be looking like this:

 採用された回答

Dave B
Dave B 2021 年 8 月 11 日
編集済み: Dave B 2021 年 8 月 11 日

1 投票

If you have access to signal processing toolbox you can do this with pulstrain
I'm sure there's a cleaner/clearer way to use this but here's what I worked out for an arbitrary width and frequency. Note that each pulse has a time and amplitude, you can make the amplitude +/-1 to achieve a biphasic pulse.
t=linspace(0,1,1000);
w = .02;
dPos = .1:.1:1;
dNeg = dPos + w;
dT = [dPos dNeg]';
dAmp = [ones(numel(dPos),1); -1 * ones(numel(dNeg),1)];
y = pulstran(t,[dT dAmp],'rectpuls',w);
plot(t,y)
ylim padded

4 件のコメント

so if i wanted to make any function biphasic like lets say a sine function, i could place the funtion into the pulstran right? but how would you place the parameters?
i tried to do something like this but it did not work out
Y = pulstran(T,D,sin(4*pi*f*t));
Dave B
Dave B 2021 年 8 月 12 日
編集済み: Dave B 2021 年 8 月 12 日
This would look a little more like
y=pulstran(T,D,@(x)sin(x*2*pi))
Otherwise MATLAB is just going to evaluate the sin() and treat that argument like the numeric result.
There's a more detailed example of a custom function on the pulstrain documentation page and some general strategies for passing extra function parameters here.
thank you!!!

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by