0% found this document useful (0 votes)
29 views3 pages

Lecture: 1-4 1. Now The 2 Main Data Types in MATLAB:-scalars and Matrices or Arrays or Vectors

The document discusses MATLAB data types and generating Fibonacci series using for and while loops. It notes that the main data types in MATLAB are scalars and matrices/arrays/vectors. It then provides code to generate a Fibonacci series of length 10 using a for loop, initializing the series to [1,1] and calculating each new term as the sum of the previous two. A second code example generates the Fibonacci series until the last term exceeds 200, using a while loop to repeatedly calculate the new term and add it to the series array.

Uploaded by

chuneshphysics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views3 pages

Lecture: 1-4 1. Now The 2 Main Data Types in MATLAB:-scalars and Matrices or Arrays or Vectors

The document discusses MATLAB data types and generating Fibonacci series using for and while loops. It notes that the main data types in MATLAB are scalars and matrices/arrays/vectors. It then provides code to generate a Fibonacci series of length 10 using a for loop, initializing the series to [1,1] and calculating each new term as the sum of the previous two. A second code example generates the Fibonacci series until the last term exceeds 200, using a while loop to repeatedly calculate the new term and add it to the series array.

Uploaded by

chuneshphysics
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lecture: 1-4

1. Now the 2 main data types in MATLAB :- scalars and matrices or arrays or vectors.

2.
3.

4.

5. Fibonnachi Series:- Using For loop

%%Fibonacchi Series using For loop%%


n=10;
fibo=[1,1];
for i=3:n
fibo(i)=fibo(i-1)+fibo(i-2);
end

6. Fibo using while

%%Fibonacchi Series using while loop%%


fibo=[1,1];
while (fibo(end)<200)
fibonew=fibo(end) + fibo(end-1);
fibo=[fibo,fibonew];
end

Solution:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy