Compacting a For Loop
古いコメントを表示
Hi all
I would love some help with compacting a for loop, i'm using it to find the smallest error in a matrix is there a way of finding the smallest value of the matrix as well as the name of the variable associated with the smallest value other then printing out a masive for loop.
Thanks Ben.
2 件のコメント
Sindar
2020 年 10 月 7 日
- post code in blocks, don't attach unless it's really long:
norm_er = 1.301;
exp_er = 9.126;
log_er = 1.301;
ray_er = 2.606;
Errors = [norm_er,exp_er,log_er,ray_er]
if norm_er<exp_er && norm_er<log_er && norm_er<ray_er
disp('Normal distribution is best')
elseif exp_er<norm_er && exp_er<log_er && exp_er<ray_er
disp('Exponential distribution is best')
elseif log_er<norm_er && log_er<exp_er && log_er<ray_er
disp('Log distribution is best')
elseif ray_er<norm_er && ray_er<exp_er && ray_er<log_er
disp('Rayleigh distribution is best')
elseif norm_er==exp_er
disp('Normal and Exponential distributions are best')
elseif norm_er==log_er
disp('Normal and Log distributions are best')
elseif norm_er==ray_er
disp('Normal and Rayleigh distributions are best')
elseif exp_er==log_er
disp('Exponential and Log distributions are best')
elseif exp_er==ray_er
disp('Exponential and Rayleigh distributions are best')
elseif log_er==ray_er
disp('Log and Rayleigh distributions are best')
end
- that's not a for loop
- is there an actual appreciable chance that two methods will give the same error?
Benedict Comerford
2020 年 10 月 7 日
採用された回答
その他の回答 (1 件)
Benedict Comerford
2020 年 10 月 7 日
0 投票
2 件のコメント
Benedict Comerford
2020 年 10 月 7 日
Sindar
2020 年 10 月 7 日
yup, had a typo / holdover from a first draft
カテゴリ
ヘルプ センター および File Exchange で Signal Generation, Analysis, and Preprocessing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!