how to change dot notation to if else if structure, with while and for loops.

1 回表示 (過去 30 日間)
Jeremy Hiesler
Jeremy Hiesler 2020 年 10 月 12 日
回答済み: Athul Prakash 2020 年 10 月 15 日
Say I try to evaluate this function with the dot notations, how would I proceed on changing this to the form desired.
f=@(t) 2*F0.*t.*(t>-0.5*T0).*(t<=0.5.*T0)+ ...
(2*F0.*t+2).*(t>-T0).*(t<=-0.5.*T0)+ ...
(2*F0.*t-2).*(t>0.5*T0).*(t<=T0);
f=@(t1) 2*F1.*t1.*(t1>-0.5*T1).*(t1<=0.5.*T1)+ ...
(2*F1.*t1+2).*(t1>-T1).*(t1<=-0.5.*T1)+ ...
(2*F1.*t1-2).*(t1>0.5*T1).*(t1<=T1);
  3 件のコメント
Jeremy Hiesler
Jeremy Hiesler 2020 年 10 月 12 日
Tbh i have no idea what dot notation is. I am trying to figure it out. But my professor says we cant use dot notation, so im trying to figure out how to read the code to then transfer.
Rik
Rik 2020 年 10 月 13 日
I suspect your professor wants you to undo all the beautiful array operations, which is the reverse of what you should normally do.
How much of the basic Matlab syntax do you understand? Are you currently doing a Matlab course?

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

回答 (1 件)

Athul Prakash
Athul Prakash 2020 年 10 月 15 日
I'm not certain what sort of 'dot notation' is in question here.
The '.' - dots in your code are multiplication operators. In Matlab, there are two kinds of multiplication operators
1) * [star/asterisk]
2) .* [dot followed by star]
The former performs matrix multiplication and the latter is used for element-wise multiplications.
I hope this helps you understand your code better and clears up what the dots mean.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by