store all values of variable

1 回表示 (過去 30 日間)
abdul rehman
abdul rehman 2020 年 7 月 8 日
コメント済み: Stephen23 2020 年 7 月 8 日
----------
In follwing code how can I store all the values (1-100) of "mean" varialbe in its tabular file(excel type of file, varialbe file). Now by defalt only last value is stored. I am also attaching the screen shot of varialbe file. I also want to plot the graph of that mean, but that is additional task.
----------
for i=1:1:100
Rep_veh=rand(1)
Rep_veh1=rand(1)
Rep_veh2=rand(1)
mean=(Rep_veh+Rep_veh1+Rep_veh2)/3
if mean>0.5
disp('report is trusted')
elseif mean<=0.5
disp('report is not trusted')
end
end
  1 件のコメント
Stephen23
Stephen23 2020 年 7 月 8 日
How to use loops and store their oututs is explained in the introdcutory tutorials:
It also introduces simpler, vectorized approaches to your problem.

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

採用された回答

madhan ravi
madhan ravi 2020 年 7 月 8 日
Rep_veh = rand(100,1);
Rep_veh1 = rand(100,1);
Rep_veh2 = rand(100,1);
MEAN =(Rep_veh+Rep_veh1+Rep_veh2)/3;
c = {'report is trusted', 'report is not trusted'};
M = c((MEAN <= 0.5) + 1)
doc for

その他の回答 (0 件)

カテゴリ

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