How to create a vector based on another vector in a for loop?

I would like to create a vector based on another vector, how do i do that? Is it easiest to do so with a for loop? Below is the code that i have so far. But it doesn't seem to be working. What am I missing?
for Vp=[0:0.2:4];
u=Vp/A
end

回答 (1 件)

David Hill
David Hill 2022 年 4 月 12 日

0 投票

Vp=0:.2:4;
A=5;
u=Vp/A;

1 件のコメント

David Hill
David Hill 2022 年 4 月 12 日
Vp=0:.2:4;
A=5;
for k=1:length(Vp)
u(k)=Vp(k)/A;
end

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2022 年 4 月 12 日

コメント済み:

2022 年 4 月 12 日

Community Treasure Hunt

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

Start Hunting!

Translated by