MATLAB: Accessing data from 1st row to nth row from two columns and plotting them excelgraphgraph plottingimporting excel data 1 Best Answer You can use the indexing to specify the the rows and columns you want to extract.data = rand(20, 5); % example matrixx = data(2:end, 1); % row 2 to 15 from column 1y = data(2:end, 2); % row 2 to 15 from column 2plot(x,y);The above code will extract row 2 to 15 from column 1 and row 2 to 15 from column 2 and plot them. Related SolutionsMATLAB: Finding Rest of Row Do you mean like vlookup in excel? Try this:data = randi(1,4,5); % Just an example matrixfirst = data(randi(4),1); % Example of desired number in first columnindex = data(:,1) == first; % Find in which row is your desired number locatedrest = data(index,2:end); % Get the rest of columns of that row MATLAB: Finding average of every nth row This is the mean over 6 subsequent rows:x = rand(9985, 1);S = numel(x);xx = reshape(x(1:S - mod(S, 6)), 6, []);y = sum(xx, 1).' / 6;The trailing rows are ignored.[EDITED] General method for matrices:x = rand(9985, 14);p = 6;n = size(x, 1); % Length of first dimensionnc = n - mod(n, p); % Multiple of pnp = nc / p; % Length of resultxx = reshape(x(1:nC, :), p, np, []); % [p x np x size(x,2)]y = sum(xx, 1) / p; % Mean over 1st dimy = reshape(y, np, []); % Remove leading dim of length 1See also FEX: BlockMean Related QuestionHow can i choose certain rows from a matrixRowsFind minimum value in every nth rowsHow to delete every nth rowExtracting data from excel file; Adding a new column; plotting the first and the newly added column
Best Answer