필터 지우기
필터 지우기

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

조회 수: 1 (최근 30일)
Charlie Milford
Charlie Milford 2022년 8월 24일
답변: Moksh 2023년 8월 28일
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
Charlie Milford
Charlie Milford 2022년 8월 24일
Any suggestions? I think it should be relatively simple I just cant think how it would be done

댓글을 달려면 로그인하십시오.

답변 (1개)

Moksh
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!

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by