lab 3 work - Alan Shu-Ming Kwok (sk25784) ME 218 Lab...

This preview shows pages 1–4. Sign up to view the full content.

Alan Shu-Ming Kwok (sk25784) ME 218 Lab (17795) Problem 2.1.1 Enter the following commands in your m-file and run it if myValue equals 8. What size is y and what will be in each entry of y? Name Size Bytes Class Attributes y 1x8 64 double y = 1.0e+003 * 0.0027 0.0074 0.0201 0.0546 0.1484 0.4034 1.0966 2.9810 Problem 2.1.2 The following example won’t work. Why not? Hint: How would you display the second element in the vector y? Attempted to access y(1.5); index must be a positive integer or logical. Problem 2.1.3 Now Let’s try on our own. Use a for loop and MATLAB to plot the following relationship. x=1:.05:5 and y=1/x Turn in both your m-file and the plot.

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

View Full Document
>> clear; x=1:0.05:5; for i =1:length(x) y(i) = 1/x(i); end Problem 2.1.4 Edit nested.m so that row = [ 1 2 3 4 5 ] . Run the m-file. Using MATLAB vector multiplication, how can you produce the matrix A without using any FOR loops? >> row = [ 1 2 3 4 5 ]; factor = [ 1 10 100 1000 ]'; factor*row
Alan Shu-Ming Kwok (sk25784) ME 218 Lab (17795) ans = 1 2 3 4 5 10 20 30 40 50 100 200 300 400 500 1000 2000 3000 4000 5000 Problem 2.1.5 Create a script file named force.m and define force to be […] Inside the script file force.m, define x=1:20 and write a for loop around the IF statement that sets a vector F equal to Force evaluated at each x. Plot the result using plot( x, F ). Add both a title and labels for each axis. Print out a copy of the script and the plot to turn in.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/04/2011 for the course ME 218 taught by Professor Unknown during the Spring '08 term at University of Texas at Austin.

Page1 / 10

lab 3 work - Alan Shu-Ming Kwok (sk25784) ME 218 Lab...

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

View Full Document
Ask a homework question - tutors are online