Line plot of rows in a Matlab matrix with the x-axis is the maximum value -


i new here , new matlab.

i have matrix file in matlab , want make plot of average rows. however, want plot few data points (about 20) of values before, , after, maximum value within row. matrix file has 550 columns.

i have worked out how identify maximum value , column number of maximum value using;

[maxvalue maxindex] = max(filename, [], 2) 

as maximum never in same column, need in calculating average values each row (before , afer max value), , how plot maximum value 0 on x-axis.

for example - have matrix this;

 14    51   623    23     4     1     4     5  0     0     3     5    67    37    37     5  0     0     0     0   574     4     5     6 

and max value = 623 67 574

and max index = 3 5 5

so to, plot average of 3 rows, 2 data points before , after max values...so plot average of;

14, 51, 623, 23, 4, 1 3, 5, 67, 37, 37 0, 0, 574, 4, 5 

thanks help!

data = [14    51   623    23     4     1     4     5          0     0     3     5    67    37    37     5          0     0     0     0   574     4     5     6]; %// example data data = data.'; %'// it's easier work along columns [~, pos] = max(data); %// position of maxima ind = bsxfun(@plus,bsxfun(@plus, pos,(-2:2).'),(0:size(data,2)-1)*size(data,1)); %'// linear index matrix obtained pos data_trimmed = data(ind).'; %'// index , transpose data = data.'; %'// undo transpose put data shape 

result:

data_trimmed =      14    51   623    23     4      3     5    67    37    37      0     0   574     4     5 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -