Download presentation
Presentation is loading. Please wait.
Published byColleen Dennis Modified over 9 years ago
1
DUE NOW » Lab 9 - resistances
2
Your task.. Create a program that allows the user to enter as many individual resistance values (in Ohms) as the user wants. When the user wants to stop entering values, s/he will enter a negative or zero value. When done, tell the user the equivalent value in both series and parallel. DO NOT USE ARRAYS or material not taught. Use material taught in the lecture yesterday.
3
The series shouldn’t even be worth any points…
4
That part is easy (if you practice the slides) %surface counting %by Dr. Pembridge clc clear % prompt for a surface (and give directions) fprintf('Note: a negative/zero surface quits.\n'); surface = input('Enter surface (m2): '); sumSurfaces = 0; %start result at zero % while surface is positive while surface>0 % “running total”: add surfaces as they are given sumSurfaces = sumSurfaces + surface; % ask for next surface value surface = input('Next surface: '); end % display total surface to the screen fprintf('All the surfaces add up to %.4f m2.\n', sumSurfaces);
5
That part is easy (if you practice the slides) %resistance counting %by Caroline clc clear % prompt for a resistance (and give directions) fprintf('Note: a negative/zero resistance quits.\n'); resistance = input('Enter resistance (Ohms): '); sumResistances = 0; %start result at zero % while resistance is positive while resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % ask for next resistance value resistance = input('Next resistance: '); end % display total resistance to the screen fprintf('All the resistances (series) add up to %.4f Ohms.\n', sumResistances);
6
Test as you go… %resistance counting %by Caroline clc clear % prompt for a resistance (and give directions) fprintf('Note: a negative/zero resistance quits.\n'); resistance = input('Enter resistance (Ohms): '); sumResistances = 0; %start result at zero % while resistance is positive while resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % ask for next resistance value resistance = input('Next resistance: '); end % display total resistance to the screen fprintf('All the resistances (series) add up to %.4f m2.\n', sumResistances); ugh.. I need to skip lines in the output..
7
About the parallel.. inside the loop below the loop
8
Implement 3 more lines… % prompt for a resistance (and give directions) fprintf('Note: a negative/zero resistance quits.\n'); resistance = input('Enter resistance (Ohms): '); sumResistances = 0; %start result at zero denominator = 0; %start denominator at zero % while resistance is positive while resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % calculate parallel setup denominator = denominator + 1/resistance; % ask for next resistance value resistance = input('Next resistance: '); end % display both resistance equivalent to the screen fprintf(‘\nAll the resistances (series) add up to %.4f Ohms.\n', sumResistances); fprintf('and in parallel, it''ll be equivalent to %.4f Ohms.\n', 1/denominator);
9
For those adventurous ones… Add a little bit! % prompt for a resistance (and give directions) fprintf('Note: a negative/zero resistance quits.\n'); resistance = input('Enter first resistance (Ohms): '); sumResistances = 0; %start result at zero denominator = 0; %start denominator at zero res_nb = 2; %start counter to display 2 nd in loop..etc % while resistance is positive while resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % calculate parallel setup denominator = denominator + 1/resistance; % ask for next resistance value fprintf('Enter resistance #%d: ', res_nb); resistance = input(''); res_nb = res_nb+1; %update for next loop end % display both resistance equivalent to the screen fprintf('\nAll the resistances (series) add up to %.4f Ohms.\n', sumResistances); fprintf('and in parallel, it''ll be equivalent to %.4f Ohms.\n', 1/denominator);
10
TEST!!! Add a little bit! % prompt for a resistance (and give directions) fprintf('Note: a negative/zero resistance quits.\n'); resistance = input('Enter first resistance (Ohms): '); sumResistances = 0; %start result at zero denominator = 0; %start denominator at zero res_nb = 2; %start counter to display 2 nd in loop..etc % while resistance is positive while resistance >0 % calculate series setup sumResistances = sumResistances + resistance ; % calculate parallel setup denominator = denominator + 1/resistance; % ask for next resistance value fprintf('Enter resistance #%d: ', res_nb); resistance = input(''); res_nb = res_nb+1; %update for next loop end % display both resistance equivalent to the screen fprintf('\nAll the resistances (series) add up to %.4f Ohms.\n', sumResistances); fprintf('and in parallel, it''ll be equivalent to %.4f Ohms.\n', 1/denominator);
11
A variety of engineering… Lab02 – Math (Do 2 lines intersect?) Lab03/04 – Math (land purchase) & Civil (buckling) Lab05 – Civil (buckling) & Fluids (Flow through pipe) Lab06 – Civil/Aero (buckling & cement ratio) Practice Exam1 – Math & Environmental (Heating House) Exam1 – Environmental (Windmill) Lab08 – Math (tiles) Lab09 – Electrical (resistances) Lab10 – Mechanical (reduction gears)
12
Reduction gears reduction gear - gearing that reduces an input speed to a slower output speed.
13
Math is rather simple… 1 3 5 2 4 6
14
Your task…
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.