import data and plat a 3D
Ältere Kommentare anzeigen
I do have a excel file with 3 columns (x y z). I wanna import them to Matlab, and plot a nice surface Plot.i might have to interpolate?
2 Kommentare
Rik
am 20 Dez. 2019
If it is a full grid of x and y, there will be no need for interpollation. Can you share your actual data, or a functional equivalent?
Verena Salan
am 20 Dez. 2019
Antworten (2)
Rik
am 20 Dez. 2019
No interpollation required, just a conversion to a 2D matrix. You can adapt the syntax of accumarray if you do have any missing values (by default it will fill with 0).
num=xlsread('test1.xlsx');
x=num(:,1);
y=num(:,2);
P=num(:,3);
%find the unique x and y values and use them as indices to fill the Z
[X,~,x_]=unique(x);
[Y,~,y_]=unique(y);
Z=accumarray([x_,y_],P);
[X,Y]=ndgrid(X,Y);
surf(X,Y,Z)
10 Kommentare
Verena Salan
am 20 Dez. 2019
Verena Salan
am 20 Dez. 2019
Rik
am 20 Dez. 2019
The reshape method has the downside that you need to be sure about the orientation of your data. It will also fundamentally break if you don't have a complete grid.
Also note that surf will handle non-uniform spacing of values, it just needs a full grid (which is allowed to contain NaN values).
As to the question of how to get the volume: figure out a way to set the other hill to 0 and then use a 2D integration to find the volume.
Verena Salan
am 2 Jan. 2020
Rik
am 2 Jan. 2020
What have you tried?
Verena Salan
am 6 Jan. 2020
Rik
am 6 Jan. 2020
What have you tried so far?
Verena Salan
am 6 Jan. 2020
Rik
am 6 Jan. 2020
On a conceptual level, what would you do? If you needed to do it on paper, what would your approach be?
ME
am 20 Dez. 2019
0 Stimmen
I think you are correct about the need to interpolate. You could try having a read of the link below - that should give you some good pointers.
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!