HWsolution #3

# HWsolution #3 - %Engineering 6, Spring 2004, Problem 3.1...

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

%Engineering 6, Spring 2004, Problem 3.1 Solution %(Distance between two points) %Clear command window clc; %Prompt user to enter coordinates of two points x1 = input( 'Enter x-coordinate of first point: ' ); y1 = input( 'Enter y-coordinate of first point: ' ); x2 = input( 'Enter x-coordinate of second point: ' ); y2 = input( 'Enter y-coordinate of second point: ' ); %Calculate distance between two points d = sqrt((x1-x2)^2 + (y1-y2)^2); %Display result to 3 decimal places fprintf( 'The distance between the two points is %.3f\n' ,d); Displayed results: Enter x-coordinate of first point: 1.3 Enter y-coordinate of first point: -3.6 Enter x-coordinate of second point: 4.1 Enter y-coordinate of second point: 2.7 The distance between the two points is 6.894 ****************************************************************************** %Engineering 6, Spring 2004, Problem 3.2 Solution %(Complex number math) %Suppress extra lines in output and set fixed short display format compact; format short; clc; %Clear command window %Part (a): real and imaginary parts of z1

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 01/22/2011 for the course ENG 006 taught by Professor Lagerstrom during the Spring '06 term at UC Davis.

### Page1 / 4

HWsolution #3 - %Engineering 6, Spring 2004, Problem 3.1...

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

View Full Document
Ask a homework question - tutors are online