How to set two a vector greater than a variable and lower than another variable into a new matrix?

3 次查看(过去 30 天)
clc,clear,close all
aftbod = 13;
fwdbod = 138;
midbod = 78
for subit=1:10
MutCol(subit,:,:)=randi([13 138]);
if aftbod < MutCol(subit,1) & midbod > MutCol(subit,1)
aftref = MutCol;
elseif midbod < MutCol(subit,1) & fwdbod > MutCol(subit,1)
fwdref = MutCol;
end
end
this is my code, I'm trying to store all the variables that fit the requirement of being less than midbod and more than aftbod to be stored in aftref and the variables that fit the requirement of being less than fwdbod and more than midbod in fwdref
  1 个评论
Matt J
Matt J 2020-3-10
编辑:Matt J 2020-3-10
less than midbod and more than aftbod
Be mindful that using > and < ( as opposed to >= or <= ) means that elements equal to aftbod,fwdbod, or midbod will be excluded from the result.

请先登录,再进行评论。

采纳的回答

Matt J
Matt J 2020-3-10
MutCol=randi([aftbod, fwdbod],10,1);
aftref=MutCol( aftbod<MutCol & MutCol<midbod);
fwdref=MutCol( midbod<MutCol & MutCol<fwdbod);

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by