surf plot 3d - matrix multiplication
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
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 件のコメント
採用された回答
その他の回答 (1 件)
  darova
      
      
 2020 年 2 月 28 日
        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)
参考
カテゴリ
				Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

