How to find a point within a curve?

37 ビュー (過去 30 日間)
Angelavtc 2020 年 10 月 20 日
コメント済み: Angelavtc 2020 年 10 月 23 日
Hello to all,
How can I calculate a point (the red point) on the same curve but 500 units less than the point indicated in blue? (see graph). The pairs (x,y) of the curve are contained in a cell within an array. I tried with the code that I copy here, but I have problems with the “find" command, because I must be changing the absolute difference manually and since I have to automate the process, this is not an option for me. Thanks for your help!
w=1936 %This is an specific day and the graph shown here is the graph from this day
k = find(abs(Array_demand{w}.Volume- x_blue_point{w}+500) < 70,1)
%Find its correspondance within the curve for X (Volume)
%Find its correspondance within the curve for Y(Price)


Image Analyst
Image Analyst 2020 年 10 月 20 日
Try this:
% Extract the curve for X (Volume)
x = Array_demand{w}.Volume;
% Extract the curve for Y (Price)
y = Array_demand{w}.Price;
% Define blue x
bluex = 43210;
% Define red x
redx = bluex - 500
% Find index of the red x
redIndex = find(x <= redx, 1, 'last');
% Get the y value there
redy = y(redIndex)
  7 件のコメント
Angelavtc 2020 年 10 月 23 日
Wow this is wonderful! Thank you so much @Image Analyst!


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by