Not Enough Input Arguments
Afficher commentaires plus anciens
%Let the Matrix M =[1 0 0 0 0 0;0 1 0 0 0 0;0 0 1 0 0 0;0 0 0 1 0 0;0 0 0 0 1 0;0 0 0 0 0 1]
% and X = [5;2;4;1;3;6]
function [c,s]=MATH635_HW3(x1,y1)
% Construct a plane rotation that zeros the second
% component in the vector [x;y]’ (x and y are scalars)
sq = sqrt(x1^2 + y1^2);
c = x1/sq; s = y1/sq;
function M=approt(c,s,i,j,M)
% Apply a plane (plane) rotation in plane (i,j)
% to a matrix X
M([i,j],:)=[c s; -s c]*M([i,j],:);
x = [5;2;4;1;3;6];
for i=5:-1:1
[c,s] = MATH635_HW3(x(i),x(i+1));
x = approt(c,s,i,i+1,x);
end
Réponses (1)
Dyuman Joshi
le 17 Fév 2023
Déplacé(e) : Image Analyst
le 17 Fév 2023
I have modified your code, does it give the output you want?
M = eye(6);
x = [5;2;4;1;3;6];
for i=5:-1:1
[c,s] = MATH635_HW3(x(i),x(i+1));
x = approt(c,s,i,i+1,x)
end
function [c,s]=MATH635_HW3(x1,y1)
% Construct a plane rotation that zeros the second
% component in the vector [x;y]’ (x and y are scalars)
sq = sqrt(x1^2 + y1^2);
c = x1/sq; s = y1/sq;
end
function M=approt(c,s,i,j,M)
% Apply a plane (plane) rotation in plane (i,j)
% to a matrix X
M([i,j],:)=[c s; -s c]*M([i,j],:);
x = [5;2;4;1;3;6];
end
Catégories
En savoir plus sur Installing Products dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!