Question

Create a MATLAB for the following: A system is needed in which the user supplies two...

Create a MATLAB for the following:

A system is needed in which the user supplies two values that are used to compute a numeric series. These values become the starting point of the series, and the program will use them to compute the subsequent terms by adding each of the previous two values together. For example, if the user inputs the numbers 2 and 5, the series would begin as follows:

            2, 5, 7, 12, 19, 31, 50, 81, 131, …

The system should print each new value up until the point is reached that the data is no longer valid due to data storage limitations (based on the data type selected).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please let me know if you need more information:-

===========================================

%prompt = 'What is first value? '; %Actual
%prev = input(prompt) %Actual
%prompt = 'What is second value? '; %Actual
%curr = input(prompt) %Actual

prev = 2; %Testing purpose
curr = 5; %Testing purpose
fprintf('%i ', prev)

while curr < 51 %Testing purpose
%while curr < intmax %Actual
fprintf('%i ', curr)
curr = prev + curr;
prev = curr - prev;
end

=============================================

==

OUTPUT:-

--

2 5 7 12 19 31 50

==

===

Thanks

Add a comment
Know the answer?
Add Answer to:
Create a MATLAB for the following: A system is needed in which the user supplies two...
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