Borrar filtros
Borrar filtros

how to plot 3D using a txt file

40 visualizaciones (últimos 30 días)
Nagendra Kamath
Nagendra Kamath el 23 de Sept. de 2020
Comentada: Ameer Hamza el 23 de Sept. de 2020
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 comentarios
Steve Eddins
Steve Eddins el 23 de Sept. de 2020
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 el 23 de Sept. de 2020
first column is theta
second one is phi
third is Ds
I wanted plot of theta vs phi vs Ds

Iniciar sesión para comentar.

Respuesta aceptada

Ameer Hamza
Ameer Hamza el 23 de Sept. de 2020
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);
  2 comentarios
Nagendra Kamath
Nagendra Kamath el 23 de Sept. de 2020
Thank you it worked
Ameer Hamza
Ameer Hamza el 23 de Sept. de 2020
I am glad to be of help!!!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by