How to save output from the for loop in a matrixs?

Hi i have a matrix with M x n dimension. I have performed the peak analysis for each column in the for loop. I want to save the output for the for loop as a matrix.

I have used the following for loop.

for i=x
[pks,locs]=findpeaks((i),'MinPeakHeight',Thresold)
end

I get output like this :

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

You can’t pass (i) into findpeaks() — that’s just a loop iterator, not a signal. You need to extract the column from your matrix. Then, since each column is not guaranteed to have the same number of peaks, you’ll need a cell array to store the results.

[rows, columns] = size(data) % Size of your 2-D matrix of signals.
allPeakValues = cell(1, columns);
allPeakIndexes = cell(1, columns);
for col = 1 : columns
% Extract one column from the matrix.
thisColumn = data(:, col);
% Find the peaks in that column.

SEE COMPLETE ANSWER CLICK THE LINK

https://www.matlabsolutions.com/resources/how-to-save-output-from-the-for-loop-in-a-matrixs-.php

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.