if and else loop problem

1 visualizzazione (ultimi 30 giorni)
CHANDRABHAN Singh
CHANDRABHAN Singh il 26 Dic 2021
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 Commenti
Walter Roberson
Walter Roberson il 4 Gen 2022
Maybe use polyshape() objects and intersect() ?
CHANDRABHAN Singh
CHANDRABHAN Singh il 5 Gen 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);

Accedi per commentare.

Risposte (1)

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

Prodotti


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by