solution10

solution10 - switch-case solution Enter the displacement of...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
6/27/08 12:38 PM C:\Program Files\MATLAB704\work\ENME217_07_Ass10Sol.m 1 of 1 % Assignment # 10 disp('switch-case solution') x=input('Enter the displacement of the tray, x, in mm: ') S=input('Enter 1 if x<=20 mm. Enter 2 if x>20 mm. ') switch S case 1 W=1600*x case 2 W=(1600*x+1700*(x-20)) end fprintf('weight=%4.2f N\n',W) disp('if-else solution') x=input('Enter the displacement of the tray, x, in mm: ') if x<=20 W=1600*x else W=(1600*x+1700*(x-20)) end fprintf('weight=%4.2f N\n',W) disp(' ') % Calculations shown below were copied from the Command Window
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: switch-case solution Enter the displacement of the tray, x, in mm: 16 Enter 1 if x&lt;=20 mm. Enter 2 if x&gt;20 mm. 1 weight=25.60 N if-else solution Enter the displacement of the tray, x, in mm: 16 weight=25.60 N switch-case solution Enter the displacement of the tray, x, in mm: 23 Enter 1 if x&lt;=20 mm. Enter 2 if x&gt;20 mm. 2 weight=41.90 N if-else solution Enter the displacement of the tray, x, in mm: 23 weight=41.90 N...
View Full Document

This note was uploaded on 02/27/2010 for the course ENME 271 taught by Professor Marks during the Summer '08 term at Maryland.

Ask a homework question - tutors are online