Monday, 15 September 2014

MATLAB accessing conditional values and performing operation in single column -



MATLAB accessing conditional values and performing operation in single column -

just started matlab 2 days ago , can't figure out non-loop method (since read slow/inefficient , matlab has improve alternatives) perform simple task. have matrix of 5 columns , 270 rows. want is:

if value of element in column 5 of matrix goodm below 90, want take element , and subtract 90.

so far tried: test = goodm(:,5) <= 90;

goodm(test) = 999;

it changes goodm values within column 1 not 5 999, in add-on method doesn't allow me perform operations on elements below 90 in column 5. elegant solution doing this?

edit:: goodm(:,5)(test) = 999; doesn't seem work either have no thought specify target column.

i assuming looking operate on elements have values below 90 text in question reads, rather 'below or equal to' represented '<=' used in code. seek -

ind = find(goodm(:,5) < 90) %// find indices in column 5 have values less 90 goodm(ind,5) = 90 - goodm(ind,5) %// operate on elements using indices obtained previous step

matlab

No comments:

Post a Comment