필터 지우기
필터 지우기

changing value in a 2d array

조회 수: 59 (최근 30일)
charlie
charlie 2011년 7월 11일
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?

채택된 답변

Rick Rosson
Rick Rosson 2011년 7월 11일
Please try the following:
A(1,1) = 1;
A(1,100) = 1;
A(1,1000) = 1;
HTH.
  댓글 수: 1
charlie
charlie 2011년 7월 11일
please see my response below, many thanks

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 7월 11일
A(1,[1 100 1000]) = 1;
  댓글 수: 1
charlie
charlie 2011년 7월 11일
please see my response below, many thanks

댓글을 달려면 로그인하십시오.


charlie
charlie 2011년 7월 11일
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
bym
bym 2011년 7월 12일
agree with Oleg, just didn't post soon enough!
charlie
charlie 2011년 7월 12일
thank you very much, you guys are awsome

댓글을 달려면 로그인하십시오.

카테고리

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