Graph 3D Spheres

10 vues (au cours des 30 derniers jours)
Gustavo Gabriel
Gustavo Gabriel le 7 Avr 2024
Réponse apportée : Voss le 24 Avr 2024
Buenos dias Comunidad! Intente agregar comentarios a mi post anterior, pero me dice que es imposible cargarlo, que algo salio mal.
Asi que aca va de nuevo.
Ya me respondieron sobre como graficar esferas o volumenes 3D desde un archivos (Gracias Voss!!).
Ahora tengo esta situacion, necesito hacer lo mismo, pero un archivo que tiene menos datos.
como se puede modificar el script para que lea una matriz de 12x12? (La anterior era de 24x24)
Adjunto el file para ilustrar...
Muchas gracias!
Good morning Community! I tried to add comments to my previous post, but it tells me that it is impossible to load it, that something went wrong.
So here it goes again.
They already answered me about how to graph 3D spheres or volumes from a file (Thanks Voss!!).
Now I have this situation, I need to do the same thing, but a file that has less data.
How can you modify the script so that it reads a 12x12 matrix? (The previous one was 24x24)
I attach the file to illustrate...
Thank you so much!
  1 commentaire
Gustavo Gabriel
Gustavo Gabriel le 8 Avr 2024
Modifié(e) : Matt J le 8 Avr 2024
FYI this is the script Voss share with us and the one Im trying to male it work with the new file:
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
[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)

Connectez-vous pour commenter.

Réponses (1)

Voss
Voss le 24 Avr 2024
M = readmatrix('New Sphere 3D.txt');
angles = M(1,1:end-1);
z = M(2:end,1);
M(1,:) = [];
M(:,1) = [];
whos M z angles
Name Size Bytes Class Attributes M 12x12 1152 double angles 1x12 96 double z 12x1 96 double
disp(M)
0 21 35 24 -3 -31 -60 -56 -36 3 6 6 209 222 273 288 266 248 203 152 206 284 271 237 348 345 207 169 228 302 269 136 139 243 323 415 454 526 608 583 414 418 307 302 417 807 807 564 739 778 200 -64 260 434 343 441 489 428 510 792 73 272 702 280 -223 -221 -196 34 423 527 607 134 17 88 -469 -453 -406 -133 -166 362 492 -225 -449 60 -765 -712 -459 -351 -995 -924 -865 -440 -136 -165 -549 -553 -1270 -1266 -1088 -1155 -1243 -1252 -1059 -853 -767 -836 -934 -1120 -1154 -1227 -1321 -1349 -1271 -1310 -1225 -1119 -1069 -1185 -1273 -1174 -1555 -1567 -1484 -1434 -1481 -1540 -1519 -1429 -1295 -1273 -1398 -1507 -1441 -1446 -1434 -1432 -1455 -1471 -1460 -1423 -1364 -1337 -1361 -1410

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by