Buenos dias Comunidad, Necesito de su ayuda y experiencia.
La pregunta es: ¿Como puedo leer el contenido del archivo y graficar la esfera en 3D?
Muchas gracias por su ayuda!
Saludos.

1 commentaire

DGM
DGM le 13 Mar 2024
It would help to upload the text file, or a similarly-formatted example.

Connectez-vous pour commenter.

 Réponse acceptée

Voss
Voss le 14 Mar 2024

0 votes

Here's one way you can read that file and get useful information out of it:
M = readmatrix('Matrix Sphere.txt');
idx = find(all(isnan(M),2),1);
M(idx,:) = [];
M = [M(1:idx-1,:) M(idx:end,:)];
M(1,:) = M(1,[end 1:end-1]);
idx = find(isnan(M(1,:)));
z = M(2:end,idx(1));
M(:,idx) = [];
angles = M(1,:);
M(1,:) = [];
angles, z, M
angles = 1×24
0 15 30 45 60 75 90 105 120 135 150 165 180 195 210 225 240 255 270 285 300 315 330 345
z = 24×1
1 2 3 4 5 6 7 8 9 10
M = 24×24
258.8000 259.1000 259.3000 259.3000 259.2000 259.0000 258.7000 258.4000 258.0000 257.6000 257.1000 256.7000 256.2000 255.8000 255.5000 255.3000 255.3000 255.4000 255.7000 256.1000 256.7000 257.3000 257.9000 258.4000 268.8000 269.2000 269.3000 269.1000 268.8000 268.4000 267.9000 267.4000 266.9000 266.2000 265.4000 264.5000 263.6000 262.7000 261.9000 261.4000 261.3000 261.5000 262.0000 262.9000 264.1000 265.4000 266.8000 267.9000 270.6000 270.8000 270.5000 269.9000 269.3000 268.8000 268.5000 268.1000 267.6000 267.0000 266.1000 265.2000 264.1000 263.0000 262.0000 261.4000 261.4000 261.8000 262.5000 263.4000 264.7000 266.4000 268.1000 269.6000 260.8000 260.7000 260.1000 259.3000 258.6000 258.1000 257.9000 257.7000 257.2000 256.6000 256.0000 255.5000 254.8000 254.0000 253.3000 253.1000 253.6000 254.3000 254.9000 255.2000 255.8000 257.0000 258.6000 260.1000 253.8000 253.5000 253.1000 252.7000 252.2000 251.7000 251.5000 251.2000 250.4000 249.5000 249.1000 249.2000 249.3000 249.2000 249.3000 250.1000 251.4000 252.6000 252.9000 252.4000 251.8000 251.9000 252.8000 253.7000 261.3000 261.2000 261.4000 261.7000 261.8000 261.6000 261.1000 260.4000 258.7000 257.1000 256.6000 256.9000 257.6000 258.6000 259.6000 261.1000 263.1000 264.6000 265.2000 265.0000 263.9000 262.9000 262.3000 261.7000 270.4000 271.0000 271.3000 272.2000 273.1000 272.9000 271.8000 270.6000 268.3000 265.9000 264.8000 264.1000 264.5000 266.6000 268.3000 269.6000 271.3000 272.7000 274.7000 276.9000 277.7000 276.6000 273.5000 270.6000 263.8000 265.1000 264.2000 265.2000 266.7000 266.0000 263.9000 262.8000 260.3000 257.6000 255.7000 253.3000 252.6000 255.5000 257.0000 256.9000 257.7000 259.2000 263.0000 268.4000 272.9000 274.1000 268.2000 262.5000 257.6000 258.8000 255.9000 257.2000 259.0000 257.1000 253.7000 253.4000 251.7000 249.3000 247.1000 242.8000 240.9000 244.3000 244.6000 242.6000 243.6000 246.4000 250.2000 255.7000 263.4000 269.2000 261.9000 254.2000 272.2000 271.8000 267.8000 269.6000 271.5000 268.4000 264.6000 265.6000 264.4000 262.3000 260.5000 255.5000 253.3000 256.1000 255.2000 252.8000 256.0000 261.5000 262.5000 263.4000 271.6000 282.6000 276.3000 268.1000
What does the 24x24 matrix represent? You said it's values in XYZ, but that doesn't make sense to me since there's only one value for each (angle,Z) pair.
If I assume the elements of M are radii, then I get points that are close to the lateral surface of a cylinder.
[x,y] = pol2cart(deg2rad(angles),M);
figure
plot3(x,y,z,'.')
figure
x_surf = x(:,[1:end 1]);
y_surf = y(:,[1:end 1]);
z_surf = z(:,ones(1,numel(angles)+1));
surf(x_surf,y_surf,z_surf)

Plus de réponses (0)

Catégories

En savoir plus sur Functions dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by