how to make a variable to be increasing and decreasing by a specified percentage over sections

2 ビュー (過去 30 日間)
segun
segun 2014 年 4 月 21 日
コメント済み: segun 2014 年 4 月 22 日
I need syntax to make z to be increasing and decreasing by 2% over 20 sections as inputs and display 20 outputs as shown below :
f = 100;
z = 200 ;% how to make it to be increasing and decreasing by 2 % over 20 sections
b = 2; c = 4;
Y = f*b*c*z;
disp(Y);

回答 (1 件)

hossein
hossein 2014 年 4 月 21 日
Is it necessary to use 20 sections? Why not using a for loop?
f = 100;
b = 2;
c = 4;
for i = 1:20
z = 200 * (1 - 0.02 * (i-10) );
Y = f*b*c*z;
disp(Y);
end
  1 件のコメント
segun
segun 2014 年 4 月 22 日
You are right. Please send me the for loop method I will appreciate it. thanks

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

Community Treasure Hunt

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

Start Hunting!

Translated by