I can't figure out how to ask for the number of resistors that has to be an integer up to 10 and then use a loop to enter R1, R2, ... Rn

1 vue (au cours des 30 derniers jours)
My homework says to ask if the combination is in series or parallel and I believe I have that done but then I need it to ask for the number of resistors (integer up to 10) and also use a loop to enter R1, R2, ...Rn
So far I have
C=input('Input if the combination is in series or parallel: ','series','parallel');
n=input('Enter the number or resistors');
>> while n=int32(n)
n=input('Enter the number of resistors: ');
fprintf('Enter an integer up to 10')
end
I'm not sure if this is even right for n and can't figure out how to ask the user to input value for R1, R2...
  4 commentaires
Rik
Rik le 17 Fév 2020
Read the linked page. Your professor not helping you doesn't make your question urgent. Just remove the word urgent from your question, because that only causes people to ignore the rest of the question.
Walter Roberson
Walter Roberson le 18 Fév 2020
An assignment due soon is "time sensitive", not "urgent".

Connectez-vous pour commenter.

Réponses (1)

Joel Bay
Joel Bay le 17 Fév 2020
Just need to prompt the user for each resistor, changing the prompt via format specifiers.
for i = 1:n
msg = sprintf('Enter Resistance of Resistor R%d: ', i);
R(i) = input(msg);
end

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by