while/for loop

1 回表示 (過去 30 日間)
Arashdeep Dhillon
Arashdeep Dhillon 2019 年 4 月 17 日
回答済み: dpb 2019 年 4 月 17 日
So I have a vector V of which i found its length and i hv used fprintf to print the statement. Now how do i create a new vector from that doubles the elements that are positive and divisible by 3 or 5, raises to the power of 3 the elements that are negative but greater than -5 and excludes all other elements. I know i have to use a for or while loop for this but how would i do so?

回答 (1 件)

dpb
dpb 2019 年 4 月 17 日
"know i have to use a for or while loop..."
Not with Matlab, no! Use Logical indexing (link) as illustrated...

カテゴリ

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