Not Enough Input Arguments

%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

Antworten (1)

Dyuman Joshi
Dyuman Joshi am 17 Feb. 2023
Verschoben: Image Analyst am 17 Feb. 2023

0 Stimmen

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
x = 6×1
5.0000 2.0000 4.0000 1.0000 6.7082 0
x = 6×1
5.0000 2.0000 4.0000 6.7823 0 0
x = 6×1
5.0000 2.0000 7.8740 0 0 0
x = 6×1
5.0000 8.1240 -0.0000 0 0 0
x = 6×1
9.5394 0.0000 -0.0000 0 0 0
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

Kategorien

Mehr zu Installing Products finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2022b

Gefragt:

am 17 Feb. 2023

Bearbeitet:

am 17 Feb. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by