lab7 - CSC 113, Fall 2010 Lab Assignment 7 All example...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CSC 113, Fall 2010 Lab Assignment 7 All example functions or scripts below should be created in your editor and saved to your workspace, so that you may run them. 1. Consider the following M ATLAB function which accepts a two-element vector, and plots it as a vector in the plane: function handle = vectorplot(xvec) % % Plots a 2-element vector in the plane, specified by % the coordinates contained in xvec, and returns a handle to % the line so drawn. handle = line ([0 xvec(1)],[0 xvec(2)],’linewidth’,2); end Save the function as “vectorplot.m” and test it by creating the following script: % Create a figure on which to draw figure (1) clf ; % set the axis ranges axis ([-1 1 -1 1]); hold on % put a circle at the origin: plot (0,0,’o’) % % Plot a vector, and place an "x" at its end: xvec = [0.9 0.3]; vectorplot(xvec); plot (xvec(1), xvec(2), ’x’); % Another one yvec = [-0.6 -0.6]; vectorplot(yvec); plot (yvec(1), yvec(2), ’x’); 2. Suppose we create a 2 × 2 matrix with the following script:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

lab7 - CSC 113, Fall 2010 Lab Assignment 7 All example...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online