How to implement a formula involving several elements of the same vector?
Show older comments
Suppose we have two row vectors
Time = [ 1 2 3 4 5 6 7 8 9 10];
width= [0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0]; % width of peaks
There is a formula for peak resolution = (t2-t1)/(2*(w2+w1)), where t2 is element of Time(1,2) and t1 is element of Time(1,1). Similarly, w1 and w2 correspond to elements width(1,1) and width(1,2) respectively. With that one should be able to generate a row vector with 9 elements instead of individually calculating those nine values. In such cases how should we implement a formula involving several elements of the same vector?
Could someone also point out an intermediate level reference which discusses the sytax for operating on several elements of the same row or column vector to produce another vector of different dimension such as in this case? Thanks.
Accepted Answer
More Answers (1)
madhan ravi
on 23 Sep 2019
Edited: madhan ravi
on 23 Sep 2019
https://in.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html - for better understanding
peak_resolution = (Time(2:end)-Time(1:end-1))./...
(2*(Width(2:end)+Width(1:end-1))) % if understood correctly
doc colon
doc end
Categories
Find more on Logical 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!