Table printing null values until it satisfies the if condition
Show older comments
Hello. I'm new to matlab. I'm trying to create a table based on an if condition. But the output table is printing null values until it reaches the row where it satifies the condition. So my table basically has a number of null rows before listing the actual rows I wanted. I think I must use an else block to skip if it doesn't meet my if condition but I don't know how to do that. I also came across something called logical indexing "output_table(condition, column) = value;" but I don't know how to use it. Please help. Thanks in advance.
if (type(j) == 4 && TypeProb (j) >= 25)
count = count+1;
box = i;
Var1(j,:)=type(j);
Var2(j,:)=dx(j);
Var3(j,:)=dy(j);
Var4(j,:)=vehicle_vx(j);
Var5(j,:)=vehicle_vy(j);
Var6(j,:)=vehicle_poslat(j);
Var7(j,:)=vehicle_poslong(j);
Var8(j,:)=timestamp(j);
Var9(j,:)=box;
Var10(j,:)=TypeProb(j);
T1 = table(Var1,Var2,Var3,Var4,Var5,Var6,Var7,Var8,Var9,Var10,'VariableNames',Varname);
end
writetable(T1,'QW.xls');
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!