필터 지우기
필터 지우기

Schröder number with formula

조회 수: 2 (최근 30일)
Zoltán Vranka
Zoltán Vranka 2020년 2월 21일
댓글: Giuseppe Inghilterra 2020년 2월 23일
Dear All,
Could you please help me solve the problem seen below?
Create a Matlab script file, which asks the user for a 'n' number and the program displays the 'n'th Schröder number (for example n=9, 9th number).
Thank you in advance!!
  댓글 수: 2
David Hill
David Hill 2020년 2월 21일
What have you done so far?
Zoltán Vranka
Zoltán Vranka 2020년 2월 21일
Unfortunately nothing...new to this whole matlab world, but somehow this needs to be solved..:')

댓글을 달려면 로그인하십시오.

답변 (1개)

Giuseppe Inghilterra
Giuseppe Inghilterra 2020년 2월 21일
I show you how you could solve your problem.
Try this code:
prompt = 'n: ';
n = input(prompt); % ask the user for a 'n' number
S = zeros(1,n); % init Schroder number vector
S(1) = 1; % init S0
for ii = 2:n
TempSum = 0;
for kk = 1:ii-1
TempSum = TempSum + S(kk)*S(ii-kk); % compute sum
end
S(ii) = S(ii-1) + TempSum; % compute S(n)
end
disp(num2str(S(n))) % disp to command window S(n)
In future it is important that you try to start with some code and then we can help you on how to continue/fix your code to obtain the solution.
Hope this helps.
  댓글 수: 2
Zoltán Vranka
Zoltán Vranka 2020년 2월 22일
Thank you very much!!
Giuseppe Inghilterra
Giuseppe Inghilterra 2020년 2월 23일
If it works for you, remember to mark answer as accepted.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by