how to plot 3D using a txt file

40 次查看(过去 30 天)
I want the following graph
I tried using mesh and surf it is showing error that data should be matrix not scalar my txt file is attached below please help me solve this
  2 个评论
Steve Eddins
Steve Eddins 2020-9-23
I can't figure out how the numbers in chalitp.txt correspond to the graph you are trying to make. Can you clarify what the numbers in the file mean? Which numbers are supposed to the surface height?
>> load chalitp.txt
>> chalitp
chalitp =
45.0000 90.0000 106.7730 0.9351 0.8177
90.0000 90.0000 99.4950 0.8714 0.6616
54.7356 -45.0000 97.6599 0.8553 0.6257
90.0000 45.0000 97.3437 0.8525 0.6196
65.9052 63.4349 99.3358 0.8700 0.6584
25.2394 -45.0000 101.6240 0.8900 0.7050
25.2394 45.0000 102.7843 0.9002 0.7294
90.0000 45.0000 102.8373 0.9006 0.7306
65.9052 26.5651 111.1650 0.9736 0.9228
11.4218 -45.0000 114.1827 1.0000 1.0000
Nagendra Kamath
Nagendra Kamath 2020-9-23
first column is theta
second one is phi
third is Ds
I wanted plot of theta vs phi vs Ds

请先登录,再进行评论。

采纳的回答

Ameer Hamza
Ameer Hamza 2020-9-23
I assume that first 3 columns are x, y, and z values. You need to use scatteredInterpolant
data = readmatrix('chalitp.txt');
x = data(:,1);
y = data(:,2);
z = data(:,3);
f = scatteredInterpolant(x, y, z);
xg = linspace(min(x), max(x), 20);
yg = linspace(min(y), max(y), 20);
[Xg, Yg] = meshgrid(xg, yg);
Zg = f(Xg, Yg);
surf(Xg, Yg, Zg);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by