Borrar filtros
Borrar filtros

How can I make the index output of function into an array?

1 visualización (últimos 30 días)
JJH
JJH el 16 de Nov. de 2018
Comentada: Adam Danz el 16 de Nov. de 2018
I want to use the findpeaks function in matlab to find the maxima of my data set. I can get the location of each of these maxima by using locs and the width of each peak using w. The part of my function that does this is given by the code
function [pw, q, Wavelength, Intensity] = PeakFit(filename)
SpectrumData=csvread(filename)
Wavelength=SpectrumData(2:end-1,1);
Intensity=SpectrumData(2:end-1,2);
[pks locs w]=findpeaks(Intensity,'NPeaks',5,'SortStr','descend','MinPeakDistance',10,'MinPeakProminence',1*10^-6,'MinPeakWidth',2);
lambda = Wavelength(locs);
pw = (w*0.1);
end
However, I then want to be able to use lambda and pw as arrays, so that I can do the following commands:
q = lambda./(pw/2);
qvec = [q lambda];
qfac = sortrows(qvec,2);
i.e. I want to be able to extract particular elements of lambda and pw as if they were standard matrices. How can I achieve this?
  1 comentario
Adam Danz
Adam Danz el 16 de Nov. de 2018
Q1) what is the output of Wavelegth()? This is not a builtin matlab function. I'm assuming it's a vector whose size is equal to locs. If that assumption is correct, then lambda and pw are already arrays.
Q2) If the assumption above is correct, q should also be a vector the same saize as lambda; qvec should be a matrix with 2 columns, and qfac should be a columnar vector. Is that the case? If yes, what's the problem? If not, you'll need to give us more info about the Wavelength() output.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by