Can you guys help me with my ASSIGNMENT? i just don't know how to answer it =(

3 views (last 30 days)
Can you teach my the codes of the attached problem in the picture? I will appreciate your help. thank you. =)
  2 Comments
Stephen23
Stephen23 on 15 Sep 2016
  1. When you don't bother to try solving your own homework then you won't learn anything.
  2. Copying someone's work and pretending that it is your work is called plagiarism. Look it up.
Kaye Freyssinet  Abanggan
Kaye Freyssinet Abanggan on 15 Sep 2016
noted sir. i will surely do this again my own way. thanks for the reminder. more power.

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 15 Sep 2016
Edited: Stephen23 on 15 Sep 2016
Method one: bsxfun
>> n = 5;
>> bsxfun(@plus,n:-1:0,(0:n)')
ans =
5 4 3 2 1 0
6 5 4 3 2 1
7 6 5 4 3 2
8 7 6 5 4 3
9 8 7 6 5 4
10 9 8 7 6 5
Method two: toeplitz
>> toeplitz(n:2*n,n:-1:0)
ans =
5 4 3 2 1 0
6 5 4 3 2 1
7 6 5 4 3 2
8 7 6 5 4 3
9 8 7 6 5 4
10 9 8 7 6 5
  4 Comments
Kaye Freyssinet  Abanggan
Kaye Freyssinet Abanggan on 15 Sep 2016
my instructor said we can ask help in here sir, and thats because he is also not that good in matlab. thats it. can i ask a starting code or clue to do it sir? then i'll be the one to continue it.
Stephen23
Stephen23 on 15 Sep 2016
Edited: Stephen23 on 15 Sep 2016
@Kaye Freyssinet Abanggan: one way would be to create two loops, one nested inside the other, and use indexing to access the element:
n = 5
out = zeros(n+1);
for row = 1:n+1
for col = 1:n+1
out(row,col) = ???
end
end
All you need is one addition and one subtraction where the ??? is and this will work. I will leave this up to you to figure out. These tutorials are an excellent way to start using MATLAB:

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Identification in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!