How to plot a struct with 2 fields in Matlab
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hamed Bolandi
el 17 de Jul. de 2019
Editada: Hamed Bolandi
el 18 de Jul. de 2019
I have T=81x4 struct, each member has two fields (x and y cordinate). I want to plot each row which will be 4 nodes to make a rectangular by connecting the nodes. Totally it should be 81 rectangular. I am wondering how can I plot each row of struct with 2 fields. I would appreciate if anyone can help me.
for i=1:81
plot(T(i,:).x,T(i,:).y,'.')
xlim([-50 50]);
ylim([-50 50]);
k = boundary(x,y);
hold on;
plot(x(k),y(k));
end
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230227/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230228/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230229/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230230/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/230231/image.jpeg)
0 comentarios
Respuesta aceptada
Bruno Luong
el 17 de Jul. de 2019
Try this
x=reshape([T(:).x],size(T));
y=reshape([T(:).y],size(T));
plot(x(:,[1:end 1])',y(:,[1:end 1])')
1 comentario
Más respuestas (0)
Ver también
Categorías
Más información sobre Title en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!