Question

Exercise 5 Use the function matrixTransform to visualise the effect of transformation matrix 4.6 R 2.4 -2.4 Does it behave as

function [Rx] = matrixTransform(R)
% MOD10TRANSFORM is a function which will visualise the effect of your
% 2-by-2 transformation matrix R on a set of grid points. It will also plot
% the eigenvectors of the matrix R if there are two real eigenvectors.

close all;

minX = -10;
maxX = 10;
minY = -10;
maxY = 10;
n = 10;
pad = 5;

corners = [minX, maxX, minX, maxX; maxY, maxY, minY, minY];
corners = [corners, R*corners];
corners = [min(corners(:)) max(corners(:)) min(corners(:)) max(corners(:))] + pad*[-1,1,-1,1];

A = R-eye(2);

[ evec, evals ] = eig(R)

axis(corners);
axis equal;
xLim = get(gca, 'XLim');
yLim = get(gca, 'YLim');

hold on;
if trace(R)^2-4*det(R) > 0
nick = 1;
elseif trace(R)^2-4*det(R) == 0
if isreal(eig(R))
nick = 1;
else
nick = 0;
end
else
nick = 0;
end

for t = linspace(0,1,100)
cla;
if nick
sevec = (A*t+eye(2))*evec;
quiver(0, 0, sevec(1,1)*10, sevec(2,1)*10);
quiver(0, 0, sevec(1,2)*10, sevec(2,2)*10);
end
for x = linspace(minX, maxX, n)
index = 1;
for y = linspace(minY, maxY, n)
if nick
newXY(:,index) = (A*t+eye(2))*[x;y];
  
else
[t1,r1] = cart2pol(x,y);
[t2,r2] = cart2pol(R(1)*x+R(2)*y,R(3)*x+R(4)*y);
if t2 >= t1
t2 = t2-2*pi;
end
[xp, yp] = pol2cart(t1+(t2-t1)*t, r1+(r2-r1)*t);
newXY(:, index) = [xp;yp];
end
index = index+1;
end
plot(newXY(1,:), newXY(2,:), '.', ...
'MarkerEdgeColor',[0.4 (maxX-x)/(maxX-minX) 0.8]);
plot(newXY(1,1), newXY(2,1), '.m');
plot([0, 0],yLim,'-k');
plot(xLim,[0,0],'-k');
end
  
if t == 0
pause(1);
else
pause(0.005);
end
end

end

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is an implementation in MATLAB.

We have made use of the 'eig' function of MATLAB to find out the eigenvectors and eigenvalues.

Add a comment
Know the answer?
Add Answer to:
function [Rx] = matrixTransform(R) % MOD10TRANSFORM is a function which will visualise the effect of your...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm trying to use the odeint function or the quad function to integrate my integrand in my calc_H...

    I'm trying to use the odeint function or the quad function to integrate my integrand in my calc_Hmatrix function. however I am not sure what my y0 or my t would need to be in order to get the code to run properly. please help, if more information is needed I can update this post Project1(1) (1) (1) x S ㄨ scipyintegrate.odeint--Sc | + jupyter Project1(1) ()(1r File Edit View Insert Cell Kernel Widgets Help +x4r,수+H.CCode Trusted Python 3 O...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT