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?
采纳的回答
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 个评论
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.
"...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.
.
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.
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.
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
标签
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
