- When you don't bother to try solving your own homework then you won't learn anything.
- Copying someone's work and pretending that it is your work is called plagiarism. Look it up.
Can you guys help me with my ASSIGNMENT? i just don't know how to answer it =(
3 次查看(过去 30 天)
显示 更早的评论
Can you teach my the codes of the attached problem in the picture? I will appreciate your help. thank you. =)
2 个评论
Stephen23
2016-9-15
采纳的回答
Stephen23
2016-9-15
编辑:Stephen23
2016-9-15
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 个评论
Stephen23
2016-9-15
编辑:Stephen23
2016-9-15
@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:
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!