MAKE Vector by loop and if statement

14 views (last 30 days)
Ali Ahmed
Ali Ahmed on 23 Apr 2022
Answered: KSSV on 23 Apr 2022
I need to extrat the min value of the
y(i) but it is can not be stored as vector to find min value
u=length(Datatest.Timehhmm);
for i=1:u
z= Datatest.TotalGORscfstb(i);
if min(z)>200 && (Datatest.PDPpsia(i))<=(Datatest.PIPpsia(i))
y(i)
end
end

Answers (1)

KSSV
KSSV on 23 Apr 2022
If you want to store the index:
y = zeros([],1) ;
u=length(Datatest.Timehhmm);
count = 0 ;
for i=1:u
z= Datatest.TotalGORscfstb(i);
if min(z)>200 && (Datatest.PDPpsia(i))<=(Datatest.PIPpsia(i))
count = count+1 ;
y(count) = i ;
end
end
If you want to store values:
y = zeros([],1) ;
u=length(Datatest.Timehhmm);
count = 0 ;
for i=1:u
z= Datatest.TotalGORscfstb(i);
if min(z)>200 && (Datatest.PDPpsia(i))<=(Datatest.PIPpsia(i))
count = count+1 ;
y(count) = yourvalue; % find the value
end
end

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!