필터 지우기
필터 지우기

help with a matlab code

조회 수: 5 (최근 30일)
roshan varkey
roshan varkey 2013년 12월 4일
답변: Walter Roberson 2013년 12월 4일
i have this particular code:
Board = zeros(10);
ALPHArange = 'A':'J';
Drow = ALPHArange(randi(numel(ALPHArange)));
Dcol = randi(9,1,1);
idx = find(ismember(ALPHArange, Drow));
Board(idx, Dcol:Dcol + 1) = 2;
idx = find(ismember(ALPHArange, Drow));
this line should find the index of Drow in array ALPHArange. For example, if randomly choosen alphabet is 'E' then idx will have value 5, for 'C' value 3 and so on and it will be your row number in the next line
Board(idx, Dcol:Dcol + 1) = 2;
but when i tried this,the value of .......idx = find(ismember(ALPHArange, Drow))........... is always 1,even when the randomly choosen alphabet is 'E' or 'F'........ so, all the points i try to put into matrix always ends up in the first row.

채택된 답변

Walter Roberson
Walter Roberson 2013년 12월 4일
[tf, idx] = ismember(Drow, ALPHArange);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by