changing value in a 2d array

hi, thank you for your help.
I would like to know how to change values in a 2d array. For example, I have an 2d array A as of 1000x1000, of all zero values
I want to change value in position, 1x1, 1x100, 1x1000 to value 1.
do you know a quick way of doing this?

 采纳的回答

Please try the following:
A(1,1) = 1;
A(1,100) = 1;
A(1,1000) = 1;
HTH.

更多回答(2 个)

thank you guys, when everytime i run the above function, Matlab automatically loop through the entire 1000x1000 array. as the following:
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
I dont have any for loop in there, and this took a lot of time to compelete the entire program, do you have any ideas?

4 个评论

Please post your code, or a simplified version of it that will show the problem you are having.
It doesn't loop, but it outputs the result on the command window. Use ";" as included in the code snippets to supress screen print.
agree with Oleg, just didn't post soon enough!
thank you very much, you guys are awsome

请先登录,再进行评论。

类别

在 帮助中心 和 File Exchange 中查找有关 Numeric Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by