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?

 採用された回答

Star Strider
Star Strider 2020 年 8 月 13 日

1 投票

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 件のコメント

MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 13 日
編集済み: MOHAMED ABDULAZIM 2020 年 8 月 13 日
I have data in z vector but I need to generate it's matrix too.
Star Strider
Star Strider 2020 年 8 月 13 日
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 2020 年 8 月 13 日
編集済み: dpb 2020 年 8 月 13 日
"...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...
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 13 日
Here is the data that I want to draw
Star Strider
Star Strider 2020 年 8 月 13 日
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 2020 年 8 月 13 日
編集済み: MOHAMED ABDULAZIM 2020 年 8 月 13 日
Is the readtable function available in MATLAB 2013a?
Star Strider
Star Strider 2020 年 8 月 13 日
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.
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 14 日
Thank you very much for your helpful ptompt response,Star Strider
Star Strider
Star Strider 2020 年 8 月 14 日
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 14 日
How to insert a title to the plot automatically?I am trying to type (Title'name')in the script but it didn't work.
Star Strider
Star Strider 2020 年 8 月 14 日
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.
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 14 日
Thanks a lot,Mr.Star Strider.
Star Strider
Star Strider 2020 年 8 月 14 日
As always, my pleasure!
MOHAMED ABDULAZIM
MOHAMED ABDULAZIM 2020 年 8 月 14 日
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.
Star Strider
Star Strider 2020 年 8 月 14 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2013a

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by