Question
5 matlab codes
18, Suppose I seed to fetch a mmumerical variable named hours from the user This vaniable needs to be son-orgative Ioe the em
0 0
Add a comment Improve this question Transcribed image text
Answer #1

18.

% prompt the user for the value of hours
hours = input('Enter value of hours (>= 0) : ');

% validate hours to be non-negative
while(hours < 0)
fprintf('Hours must be non-negative\n'); % if negative, display error
hours = input('Enter value of hours (>= 0) : '); % reprompt for hours
end

19.

fib = zeros(N,1); % preallocates storage for fib as N by 1 column vector

20.

fib = zeros(N,1); % preallocates storage for fib as N by 1 column vector

fib(1) = input('Enter value of fib(1) : '); % prompt for input for fib(1) value and assign it
fib(2) = input('Enter value of fib(2) : '); % prompt for input for fib(2) value and assign it

Add a comment
Know the answer?
Add Answer to:
5 matlab codes 18, Suppose I seed to fetch a mmumerical variable named hours from the user This vaniable needs to be son-orgative Ioe the emaining code in the projert to work property. so before S...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT