Working on Binary Data using MATLAB

have loaded a text file test file in matlab. The load function has now created a variable test with values
1 2 3 4 5
2 3 NaN NaN NaN
Now I have a initialized variable X = [0 0 0 0 0 0 0 0 0 0 0] and Y = [0 0 0 0 0 0 0 0 0 0 0]. I want X to read the first row of test variable and corresponding to the number it reads change its value of the element from 0 to 1. Suppose it reads 1, it should change its element X(1) from 0 to 1. Similarly Y should do the same wrt second row of test.
Any idea how should I proceed?

답변 (1개)

Walter Roberson
Walter Roberson 2011년 5월 1일

0 개 추천

X(test(1,~isnan(test(1,:)))) = 1;
Y(test(2,~isnan(test(2,:)))) = 1;

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

태그

질문:

2011년 5월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by