'Store the first N (user enters N) Fibonacci numbers in a row vector.'I know how to get user entered number of fibbonachi numbers. But I don't know how to show them in a row vector.
조회 수: 9 (최근 30일)
이전 댓글 표시
clc;
clear;
close all;
N=input('Enter the number = ');
B(1)=0;
B(2)=1;
count=1;
for i=3:N
B(1,i)=B(i-2)+B(i-1);
end
disp(B)
댓글 수: 0
채택된 답변
JESUS DAVID ARIZA ROYETH
2019년 12월 7일
clc
N=input('Enter the number = ');
B=zeros(1,N);
B(1)=0;
B(2)=1;
count=1;
for i=3:N
B(1,i)=B(i-2)+B(i-1);
end
disp(B)
댓글 수: 3
JESUS DAVID ARIZA ROYETH
2019년 12월 7일
yes but I get:
Enter the number = 10
0 1 1 2 3 5 8 13 21 34
in any case, to get rid of the second column use:
B(:,2)=[]
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!