3D Surface plot with Cartesian coordinates
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I have a set of data that represents the (x,y) Cartesian coordinates of objects in an electric grid and another vector (z) that represents the voltage at the corresponding (x,y) coordinate. I have been trying to plot a heatmap/voltage contour map/surface voltage plot (bird's eye-view of (x,y) grid with magnitude of (z) at each point) but have been unable to do so successfully.
I imagine its just a question of getting the correct matrix inputs for the 'surf(X,Y,Z)' function.
if true
% %the variations I've tried:
surf(busCoordsX, busCoordsY, busVoltsMesh);
view([0 90]);
surf(busCoordsX, busCoordsY, busVoltsMesh');
view([0 90]);
[X,Y] = meshgrid(busCoordsX, busCoordsY);
surf(X, Y, busVoltsMesh);
view([0 90]);
end
I have created a version of the plot using stem3, but it does not achieve the correct view. I can supply coordinates and bus voltages, but hopefully what I'm doing wrong is obvious (and silly). Any help would be incredible.
Thanks!
2 Kommentare
Youssef Khmou
am 15 Okt. 2013
the instructions are correct, the wrong view is not explicit so far...
Antworten (3)
Youssef Khmou
am 15 Okt. 2013
Paul,
I think reshaping will not give good results, however try these approaches,
1) Solution 1:
plot3(busCoordsX,busCoordsX,busVolts,'.')
grid on
view(-90,90)
Physical interpretation : The tension occurs when DX==DY !!!! ( to be verified).
2) Solution 2:
ZZ=diag(Z);
figure, surf(X,Y,ZZ)
shading interp
view(-63,76)
Physical interp : Random partition of the voltage in the plate .
Waiting for your answer.
0 Kommentare
Paul
am 15 Okt. 2013
Hi Youssef,
I am using my account at work, so different username. Thanks again for your suggestions. Solution 1 provides the same graph as a scatter3 plot (view at [0,90]), which is useful for verifying the circuit, but does not have the surface colormap.
For Solution 2, you wrote ZZ = diag(Z), and I initially tried this on the meshgrid(Z), but making a diagonal matrix from a 130x130x130 matrix locked up my computer. Doing diag(Z) on a 130x130 Voltage matrix returns a vector and that variable already exists. Am I interpreting your code incorrectly?
I have tried another method (code attached), using the 'griddata' function, and have a graph that somewhat does what I want, but it is not entirely correct. I am really stumped as to why surf(busCoordsX, busCoordsY, busVolts) does not work.
Thanks.
0 Kommentare
Shivam Anand
am 11 Mai 2022
x=[32 20 67 1 98 34 57 65 24 82 47 55 8 51 13 14 18 30 37 39 10 33 21 26 38 81 83 60 95 22 17 5 72 46 99 52 12 25 96 29 70 85 43 69 19 78 97 31 89 53 2 91 48 71 61 15 36 84 94 50 11 80 6 7 49 74 9 88 40 79 27 68 73 64 63 59 86 23 35 58 45 28 100 42 93 87 16 90 41 66 54 92 77 4 62 76 75 56 3 44];
y=[96 75 24 9 83 49 27 77 3 23 17 31 40 13 7 52 51 21 98 47 64 79 78 91 44 16 15 100 84 99 63 68 70 30 54 76 97 73 33 5 88 8 71 66 62 25 60 42 72 45 18 11 28 59 89 65 10 55 69 81 12 26 20 95 87 41 74 50 93 22 43 90 14 34 82 35 56 38 80 32 1 57 6 36 37 61 29 58 2 48 4 46 67 53 92 86 94 19 39 85];
z=[55 31 11 45 83 36 86 49 15 57 42 46 8 94 88 47 54 81 98 41 32 35 56 85 9 89 37 60 23 62 67 100 78 76 73 80 10 20 68 34 77 93 1 63 53 12 22 99 91 40 84 24 33 3 43 19 92 97 6 82 64 25 26 79 95 4 44 58 5 21 70 29 65 87 96 90 51 14 18 2 72 28 71 39 52 7 27 59 50 61 48 30 66 69 17 13 74 16 75 38];
xlin = linspace(min(x), max(x), 100);
ylin = linspace(min(y), max(y), 100);
[X,Y] = meshgrid(xlin, ylin);
% Z = griddata(x,y,z,X,Y,'natural');
% Z = griddata(x,y,z,X,Y,'cubic');
Z = griddata(x,y,z,X,Y,'v4');
mesh(X,Y,Z)
axis tight; hold on
plot3(x,y,z,'.','MarkerSize',15)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/994555/image.png)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Contour Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!