Clear Filters
Clear Filters

Obtain data values for a vector plotted on top of a colorplot

1 view (last 30 days)
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.
  1 Comment
Charlie Milford
Charlie Milford on 24 Aug 2022
Any suggestions? I think it should be relatively simple I just cant think how it would be done

Sign in to comment.

Answers (1)

Moksh
Moksh on 28 Aug 2023
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!

Categories

Find more on Contour Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!