Surface plot by using three vectors of the same length

How could I generate a surface plot by using three vectors of the same length and there is no relation between them?I know that I have to generate a meshgrid from x and y ,but the z vector was obtained experiamentally and there is no relation to link it to x and y to generate its mesh of the same size.So,what should Ido?

 Respuesta aceptada

Star Strider
Star Strider el 13 de Ag. de 2020
The surf plot only requires that ‘Z’ is a matrix. The ‘X’ and ‘Y’ arguments are good to have, although not necessary (and they can be vectors).
With no information about what the ‘Z’ vector actually is or what it contains, I can only suggest that to create a matrix from it will likely require the reshape function.

15 comentarios

MOHAMED ABDULAZIM
MOHAMED ABDULAZIM el 13 de Ag. de 2020
Editada: MOHAMED ABDULAZIM el 13 de Ag. de 2020
I have data in z vector but I need to generate it's matrix too.
I understand that.
You need to use reshape with it to create a matrix from it, however the structure and contents of the vector will affect how you do that. I do not have that information, so I cannot suggest how to best use reshape with it.
dpb
dpb el 13 de Ag. de 2020
Editada: dpb el 13 de Ag. de 2020
"...the z vector was obtained experiamentally and there is no relation to link it to x and y"
Then the experment was pretty-much pointless it would seem if you don't have the conditions of the independent variables recorded at the time the data were taken.
You can use scatter3 with a sequence of x,y coordinates, but to draw a surface will require more info than you have at hand unless you're leaving out some key information (like the data were recorded manually but just not entered.)
scatteredinterpolant can be used to fill in data that are scattered in location for surface plots and such; how successful will depend on the locations of the observations and how smooth the surface is.
Can't create data from nothing, whatever method is used...
Here is the data that I want to draw
Try this:
T1 = readtable('all data at Re12000.xlsx');
Q1 = T1(1:10,:);
Thm = reshape(T1.Theta1, 4, []);
Bem = reshape(T1.Beta1, 4, []);
Num = reshape(T1.Nu1, 4, []);
figure
surfc(Thm, Bem, Num)
grid on
xlabel('\theta_1')
ylabel('\beta_1')
zlabel('\nu_1')
view(70,30)
producing:
All the information necessary to plot the surface is in the file.
.
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM el 13 de Ag. de 2020
Editada: MOHAMED ABDULAZIM el 13 de Ag. de 2020
Is the readtable function available in MATLAB 2013a?
It was introduced in R2013b.
Without it, the code changes to:
D = xlsread('all data at Re12000.xlsx');
Thm = reshape(D(:,1), 4, []);
Bem = reshape(D(:,2), 4, []);
Num = reshape(D(:,3), 4, []);
The rest of the code is unchanged.
Thank you very much for your helpful ptompt response,Star Strider
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
How to insert a title to the plot automatically?I am trying to type (Title'name')in the script but it didn't work.
Use the title function.
Put it anywhere after the surfc call, and before plotting the next figure. (There are ways to assign it to specific axes if necessary, once they are created.)
It is also possible to use it with sprintf. This can make customising it easier.
Thanks a lot,Mr.Star Strider.
As always, my pleasure!
Could I save matlab figures to a certain directory and make this automatic in script file?I am writing a script file for drawing many surfaces.
Yes.
Use the saveas or print function.
Access the R2013a documentation with:
doc saveas
doc print
Use the documentation provided with R2013a, not the online documentation that I lniked to here, that is for R2020a. All the other related functions linked to in and at the end of that documentation page that I lniked to here were introduced after R2013a.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2013a

Etiquetas

Preguntada:

el 13 de Ag. de 2020

Comentada:

el 14 de Ag. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by