if and else loop problem

1 visualización (últimos 30 días)
CHANDRABHAN Singh
CHANDRABHAN Singh el 26 de Dic. de 2021
Comentada: CHANDRABHAN Singh el 5 de En. de 2022
if (loop==false && centre(ii,1)<95 )
centre(ii,:) = centre(ii,:)+ [0.1 0];
elseif (loop==false && centre(ii,2)<95)
centre(ii,:) = centre(ii,:)+ [0 0.1];
elseif (loop==false && centre(ii,1)>5)
centre(ii,:) = centre(ii,:)- [0.1 0];
elseif (loop==false && centre(ii,2)>5)
centre(ii,:) = centre(ii,:)- [0 0.1];
else
break
end
Lets's say centre(ii,1)=94.95, then the first if increases it to 95.05.
As soon as centre(ii,1)=95.05, the third condition makes it again 94.95 and the process continues. I want, once the first condition is achieved i.e. x>95, it should go to third condition. The similar case is for 2nd and 4th condition. How to do this?
  19 comentarios
Walter Roberson
Walter Roberson el 4 de En. de 2022
Maybe use polyshape() objects and intersect() ?
CHANDRABHAN Singh
CHANDRABHAN Singh el 5 de En. de 2022
@Walter Roberson, thank you for your kind support.
Let's say
these are two non interscting ploygons (shown below). How can i get a logical relationship out of this. Something like, if the polygons intersect or touch
paramter = true;
otherwise
parameter = false;
x1 =[-2.6967 -2.0891 -0.0846 1.5544 2.6872 -2.6967];
x2 = [5.6494 6.6386 6.6898 4.0313 1.3002 1.9802 5.6494];
y1 = [ 0.1340 -1.7104 -2.6987 -2.2076 -0.2624 0.1340];
y2 = [1.8624 3.4274 4.2346 6.6998 3.9686 2.2082 1.8624];
plot(x1,y1,x2,y2);
grid on;
poly1 = polyshape(x1',y1');
poly2 = polyshape(x2',y2');
polyout = intersect(poly1,poly2);

Iniciar sesión para comentar.

Respuestas (1)

Shanmukha Voggu
Shanmukha Voggu el 29 de Dic. de 2021
Hi,
Adding to comments above, This link here might be helpful.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by