Not Enough Input Arguments
Show older comments
%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
Answers (1)
Dyuman Joshi
on 17 Feb 2023
Moved: Image Analyst
on 17 Feb 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
Categories
Find more on Installing Products in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!