sine wave measure differ

1 回表示 (過去 30 日間)
seungpyo kang
seungpyo kang 2025 年 3 月 21 日
回答済み: Angelo Yeo 2025 年 3 月 22 日
function y = generate_sine()
persistent t
Ts = 0.0001;
if isempty(t)
t = 0;
end
y = sin(377 * t);
t = t + Ts;
This is sine wave generator of 60 Hz.
when the scope set up is below, that isnt 60 Hz.
but same code, that is same function block and measure with sine wave block of 60 Hz , then measure 60 Hz
why?

採用された回答

Angelo Yeo
Angelo Yeo 2025 年 3 月 22 日
For the first question, let me set the model's solver as fixed-step with sample time of 0.01. Your MATLAB Function runs every sample time and sums up by sin(377 * t). See the result below.
Now, see how the behavior changes if I change the sample time to 0.005.
As I mentioned, your MATLAB Function runs every sample time and sums up by sin(377 * t).
I do not know what exactly happens in the second model without looking into the model, but, in the first model what you might want to do is to use Clock block. Just use the Clock's output as time. In the last case below, I set the model's sample time 1/5000.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSources についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by