Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Charlie Milford
Charlie Milford le 24 Août 2022
Réponse apportée : Moksh le 28 Août 2023
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 commentaire
Charlie Milford
Charlie Milford le 24 Août 2022
Any suggestions? I think it should be relatively simple I just cant think how it would be done

Connectez-vous pour commenter.

Réponses (1)

Moksh
Moksh le 28 Août 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!

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by