How do I align two vectors similar to that done in plot?
Show older comments
I have two sets of corresponding vectors that I want to compare. The first set of vectors contain pixel intensity values for every frame Int(F), and the second set contain wavelengths of light (wvLngth(F)). From these vectors I want to produce a third vector that is pixel intensity in terms of wavelength Int(wvLngth). The problem is that vectors containing the wavelengths do not start and end at the same wavelength, nor do the wavelengths increase at the same rate.
For example:
int1Data = [1 2 3 4];
int2Data = [5 6 7 8];
wvLngth1Data = [7 9 10 11];
wvLngth2Data = [9 10 11 13];
%I can plot these two together to align them but how can I add them in the way they are plotted?
figure
plot(wvLngth1Data, int1Data);
hold on
plot(wvLngth2Data, int2Data);
%I'd like to produce something like:
intAvg = [1 3.5 4.5 5.5 8]
wvLngthComb = [7 9 10 11 13]
figure
plot(wvLngthComb, intAvg);
I've looked at things to align or interpolate the data, but I don't think I can align my data set just at the start, because the middle or end would be wrong, and I don't need Matlab to interperet what it things the missing points should be either.
Thanks in advance.
2 Comments
Jan
on 11 Jun 2019
There is no "Int(F)" in the code.
Let my summarize: You have two vectors with data, whose indices are not related to each other. Now you want to find the relation between the indeces. Based on the currently given information it looks, like there is no such relation and in consequence the job cannot be solved.
Do you have additional information about how to align the data?
Jason Powell
on 11 Jun 2019
Accepted Answer
More Answers (1)
Guillaume Erny
on 7 Mar 2021
Edited: Guillaume Erny
on 7 Mar 2021
0 votes
Hi Jason,
I always use this function when I want to compare spectroscopic date with different axes and it work perfectly
Categories
Find more on Simulink in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!