whay do we use @(t) in our code???

104 ビュー (過去 30 日間)
john malcovih dear sir
john malcovih dear sir 2011 年 3 月 1 日
f = 0.5; % Set f to whatever it's supposed to be here
S1 = @(t) sin(2*pi*f*t); S2 = @(t) 1/2 * sin(6*pi*f*t); S = @(t) S1(t) + S2(t);
T = linspace(0,1,1000); plot(T,S1(T),T,S2(T),T,S(T)); legend({'S1(t)','S2(t)','S(t)'}); in this code why do we use @(t),,,and what dose that mean????

回答 (1 件)

David Young
David Young 2011 年 3 月 1 日
You could achieve the same result more simply by computing the values without building the function, like this:
f = 0.5; % Set f to whatever it's supposed to be here
T = linspace(0,1,1000);
Y1 = sin(2*pi*f*T);
Y2 = 1/2 * sin(6*pi*f*T);
Y = Y1 + Y2;
plot(T,Y1,T,Y2,T,Y);
legend({'S1(t)','S2(t)','S(t)'});
The advantage of making the functions is that they are available for use later, but if you don't need that you might find it easier to work without them, using code like the example above.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by