I am trying to answer a test your understanding question T4.5-3 from Introduction to MATLAB for engineers 3rd edition, but i keep failing in producing this matrix. Has anybody out the completed this problem that can give me some tips?

2 ビュー (過去 30 日間)
function A = ego
A = 4;
for r = 4:6:30
for c = 4:4:30
if (r>1)&(c>1)
s = A(r-1,c)+A(r,c-1);
if s<35
A(r,c) = s;
else A(r,c) = max(A(r-1,c),A(r,c-1));
end;
end;
end
end;
  2 件のコメント
Star Strider
Star Strider 2016 年 8 月 16 日
Please post your code and a brief description of the problem. Most of us don’t have the book.
Thorsten
Thorsten 2016 年 8 月 16 日
編集済み: Thorsten 2016 年 8 月 16 日
The question is somewhat vague: Write a program to produce the following matrix. Since it is in the chapter "For loops", the solution is probably assumed to have some for-loops. BTW: The book is available at http://www.cse.cuhk.edu.hk/~cslui/CSCI1050/book.pdf

サインインしてコメントする。

採用された回答

Thorsten
Thorsten 2016 年 8 月 16 日
There are many solutions to this problem.
A(1,:) = 4:4:12;
for i = 2:4
A(i,:) = A(i-1,:) + 6;
end
  1 件のコメント
Carlyle Hickman
Carlyle Hickman 2016 年 8 月 16 日
Thank you, your solution is very clear and easy to follow. This problem was more simple than i thought.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePerformance and Memory についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by