Obtain data values for a vector plotted on top of a colorplot
1 回表示 (過去 30 日間)
古いコメントを表示
I have plotted a colour plot of current speed, with depth on the y axis and time on the x axis.
I have a line which tracks tidal elevation, with varying depths across time within the water column.
My question is: how do I recieve current speed values for each time step along my line.
Figure shown below is what I have produced so far, I'm attempting to measure the difference in current speed experienced by both the soid and dotted black lines.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1106930/image.png)
回答 (1 件)
Moksh
2023 年 8 月 28 日
Hi Charlie,
As per my understanding you have plotted the above graph in your code. So you might already have the current speed values on the y-axis and a constant speed value represented by the dotted line. So for the following part of your query you can simply create a difference vector of the same dimensions as y and use the 'abs' function of MATLAB to calculate their absolute difference.
You can you the following example code for this
% Your plotted speed values (I am using 100 random values)
y = rand(1, 100);
% Dotted line value (Constant speed value represeneted by the dotted line)
y_dot = 0.4;
% Number of speed values (Dimensions of the y-vector)
sz = size(y);
diff = zeros(sz);
for i = 1 : sz(2)
diff(i) = abs(y(i) - y_dot);
end
You can use the following documentation for further understanding of for-loops and 'abs' function in MATLAB.
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!