How do I find the phase of any point in the graph below

2 views (last 30 days)
x=[0:10:91]; str={'Phase 1','Phase 2'}; y=[0.01*(x.^2)]; xt=[30 70]; yt=[60 20]; plot(x,y,'k','LineWidth',5),xlabel('Composition'),ylabel('Temperature');
  3 Comments
Owuraku Amankwah
Owuraku Amankwah on 17 Jul 2021
The data represents a basic phase diagram. The x values are my composition values and those of y are my temperature values.
Owuraku Amankwah
Owuraku Amankwah on 17 Jul 2021
I'm supposed to find the points above and below the curve and also write a code that shows whether any input, that is température and composition, is above or below the curve drawn

Sign in to comment.

Accepted Answer

DGM
DGM on 17 Jul 2021
Edited: DGM on 17 Jul 2021
Considering that there's only one boundary of interest, it's fairly simple.
x=0:10:91;
y=0.01*x.^2;
xt=[30 70];
yt=[60 20];
str={'Phase 1','Phase 2'};
plot(x,y,'k','LineWidth',5); hold on;
plot(xt,yt,'*')
xlabel('Composition');
ylabel('Temperature');
isabovecurve = yt>(0.01*xt.^2)
That will give you a logical vector describing where each point is WRT the boundary curve.
If you don't like repeating the expression, you could do something like:
x=0:10:91;
fy = @(xx) 0.01*xx.^2; % define y as a function
y=fy(x); % and just evaluate it
xt=[30 70];
yt=[60 20];
% do all the plotting stuff
isabovecurve = yt>fy(xt) % and evaluate it again with different points
If your problem is more complicated than this example (i.e. more boundaries), then this probably isn't going to help much.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!