surf plot 3d - matrix multiplication
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
could someone let me know how to get around this problem in the code.
i need to do the following: 1- plot the surf 2- multiply with RS matrix 3- make a new surf
angle1_min=0; angle1_max=pi/2; %all 8 Octant in 3d [0-2*pi]
angle2_min=0; angle2_max=pi/2;
number1=50; number2=2500; number3=51; %xlsread
[angle1, angle2] = ndgrid(linspace(angle1_min,angle1_max,100),linspace(angle2_min,angle2_max,100)) % size 100*100 (for using surf)
x= number1*sin(angle1)*sin(angle2)
y= number2*cos(angle1)
z= number3*sin(angle1)*cos(angle2)
surf(x, y, z) % works fine
mat = [x; y; z] % size mat here 300*100 (depend on angle size)
RS = [1 0 0; 0 1 0; 0 0 1] % size 3*3
new_mat = RS * mat % Matrix Multiplication is required- RS is to be kept
surf(new_mat)
i tried to use a function with for loop that return one point for mat with the size 1*3 then i multiplied it with RS matrix. at the end i plotted all the points using surf but its not what i expected.
0 commentaires
Réponse acceptée
Plus de réponses (1)
darova
le 28 Fév 2020
You forgot about dot here (bit-wise operator)
x= number1*sin(angle1).*sin(angle2);
y= number2*cos(angle1);
z= number3*sin(angle1).*cos(angle2);
You want to rotate data
mat = [x(:); y(:); z(:)]'; % size mat here 1e4x3
RS = [1 0 0; 0 1 0; 0 0 1] % size 3*3
new_mat = RS * mat % Matrix Multiplication is required- RS is to be kept
x1 = reshape( new_mat(1,:),size(x) );
y1 = reshape( new_mat(2,:),size(y) );
z1 = reshape( new_mat(3,:),size(z) );
surf(x1,y1,z1)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots 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!