If statement with multiple condition

4 次查看(过去 30 天)
Hi,
I read few post and could not solve my issue with if statement. I have the following code but it doesn't work!
i=1;
for j = 1 : height (reduced)
if (Boarder_Lat_lower < reduced(j, 4)) && (reduced(j, 4) < Boarder_Lat_upper) && (Boarder_Long_lower < reduced (j, 5)) && (reduced (j, 5) < Boarder_Long_upper)
Selected_2011 (i, :) = reduced (j, :);
i= i+1 ;
end
end
The problem is with multiple conditions separated with "and".
Thank you for the help
  7 个评论
Walter Roberson
Walter Roberson 2016-9-22
The code would be in error if any of the Boarder_* variables are not scalars.
Kaveh Kel
Kaveh Kel 2016-9-22
Yes, the problem was with "reduced" table -- I imported the excel file as a table.
In the code, I changed the (e.g.) "reduced(j, 4)" to "reduced.Latitude (j)" and it worked. but the problem that I still have is regard to text values, that I cannot recall from the table.
I used this code:
Selected_C (i, 3) = reduced.Name (j);
("name" is one of the column title of reduced table )
but it doesn't work
Thanks!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by