Using nested for loop to alter a previous matrix

1 次查看(过去 30 天)
I need to define a 5x5 matrix with all zeros, then use a nested for loop to alter that matrix to look like
How do I go about doing this? I understand that I need to have some sort of counter to go up as each element increases down the column.

回答(1 个)

Rik
Rik 2018-3-18
Is this homework? If not, why not avoid a loop:
A =1:25;
A2=reshape(A,5,5);
  2 个评论
Image Analyst
Image Analyst 2018-3-18
Since it's homework, which means you're not allowed to turn in Birdman's code as your own (lest you get caught "cheating"), then you should have tagged it as homework in advance. But it should be easy for you to do something very similar so that it's your own work you're turning in.
Student
Student 2018-3-18
Yes of course. I was not seeking a direct solution, only how I should go about solving the problem. Nevertheless, I now understand how to go about solving it and will create a my own solution.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by