Need help to vectorize a for loop
1 次查看(过去 30 天)
显示 更早的评论
Pls help... how to vectorise this for loop
unimodal=[28 42 46 49 52 55 58 61 64 68 82]
for n=1:11
ru(n)=(unimodal(n)-min(unimodal))/(max(unimodal)-min(unimodal));
end
for n=1:11
fu(n)=(n-1)/(length(unimodal)-1)
end
for n=1:11
ju(n)=0.5*ru(n)+0.5*fu(n);
end
0 个评论
采纳的回答
David Hill
2019-12-8
unimodal=[28 42 46 49 52 55 58 61 64 68 82];
ru=(unimodal-min(unimodal))/(max(unimodal)-min(unimodal));
fu=(0:length(unimodal)-1)/(length(unimodal)-1);
ju=0.5*ru + 0.5*fu;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!