How can I connect the upper endpoint of the red curve to the red do... (2024)

46 views (last 30 days)

Show older comments

Atom on 8 Jun 2024 at 7:24

  • Link

    Direct link to this question

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea

  • Link

    Direct link to this question

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea

Edited: Image Analyst on 8 Jun 2024 at 19:18

  • BT_Hom(2).mat

Open in MATLAB Online

How can I connect the upper endpoint of the red curve to the red dot while keeping the curvature nearly the same?

clear all

format long

warning off

figure

set(0,'DefaultAxesFontSize',20);

load('BT_Hom(2).mat')

[~,idx] = max(x(326,:));

plot(x(326,1:idx-20),x(325,1:idx-20),'r', 'LineWidth',2);

hold on

axis([0.14 .18 .15 .18]);

scatter(0.174701,0.177614, 'o', 'MarkerFaceColor', 'r');

xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

How can I connect the upper endpoint of the red curve to the red do... (2)

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Answers (2)

Image Analyst on 8 Jun 2024 at 14:03

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#answer_1469056

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#answer_1469056

  • BT_Hom(2).mat

Try using plot after you use scatter to draw a line from the last point on the curve to the marker you placed with scatter():

figure

set(0,'DefaultAxesFontSize',20);

load('BT_Hom(2).mat')

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>curve_func

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>defaultprocessor

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>options

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>jacobian

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>hessians

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>testf

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>userf

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>process

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>singmat

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>locate

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>init

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>done

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\hom*oclinic\hom*oclinic.m>adapt

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\Systems\sudeshna_3.m>fun_eval

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\Systems\sudeshna_3.m>jacobian

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\Systems\sudeshna_3.m>jacobianp

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\Systems\sudeshna_3.m>hessians

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\Systems\sudeshna_3.m>hessiansp

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\Systems\sudeshna_3.m>der3

Warning: Could not find appropriate function on path loading function handle F:\1. Research\2. Mathematical Biology\MatCont7p4\MatCont7p4\GUI\ComputationConfigurations\ContCurve.m>@(dat)loaderfunction(dat)

[~,idx] = max(x(326,:));

plot(x(326,1:idx-20), x(325,1:idx-20), 'r', 'LineWidth',2);

hold on

axis([0.14 .18 .15 .18]);

scatter(0.174701,0.177614, 'o', 'MarkerFaceColor', 'r');

xTip = [x(326,1:idx-20), 0.174701];

yTip = [x(325,1:idx-20), 0.177614];

plot(xTip, yTip, 'r-', 'LineWidth', 2);

grid on;

xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

How can I connect the upper endpoint of the red curve to the red do... (4)

There will be a slight change in curvature. It it's really objectionable, you can use the scatter point and the last two points of the curve and fit a cubic to it and interpolate a bunch of points in between. Not sure it would look much different though than the straight line.

2 Comments

Show NoneHide None

Atom on 8 Jun 2024 at 14:34

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#comment_3182216

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#comment_3182216

Edited: Atom on 8 Jun 2024 at 14:37

Thank you. I tried using the straight line approach, but the curvature isn't very smooth. If the gap of curve and point is increased a bit more, it will look bad. Could you please help me with the code of the other method you mentioned?

Image Analyst on 8 Jun 2024 at 19:16

Direct link to this comment

https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#comment_3182281

  • Link

    Direct link to this comment

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#comment_3182281

Edited: Image Analyst on 8 Jun 2024 at 19:18

As you can see, Star used some more sophisticated methods and the plot looks virtually the same. Are they still not good enough? Is so, why not? What is the purpose of the plot? Who is the consumer/viewer of these plots and will they be annoyed if it's not smoother?

But realize that as the final point gets much further away, the connecting curve will have to look more and more like a line. I mean if the point was out at 0.4 or 0.5, what would you expect the connecting curve to look like? It can't be very curvy!

Sign in to comment.

Star Strider on 8 Jun 2024 at 18:36

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#answer_1469101

  • Link

    Direct link to this answer

    https://jmaab.mathworks.com/matlabcentral/answers/2126636-how-can-i-connect-the-upper-endpoint-of-the-red-curve-to-the-red-dot-while-keeping-the-curvature-nea#answer_1469101

Open in MATLAB Online

  • BT_Hom(2).mat

Here are options using pchip, makima and spline

clear all

format long

warning off

figure

set(0,'DefaultAxesFontSize',20);

load('BT_Hom(2).mat')

[~,idx] = max(x(326,:));

plot(x(326,1:idx-20),x(325,1:idx-20),'r', 'LineWidth',2);

hold on

axis([0.14 .18 .15 .18]);

scatter(0.174701,0.177614, 'o', 'MarkerFaceColor', 'r');

% line_end = [x(326,idx-20),x(325,idx-20)];

line_end = [x(326,idx-21:idx-20);x(325,idx-21:idx-20)];

scatter_point = [0.174701,0.17761];

connecting_line(1,:) = linspace(line_end(1), scatter_point(1), 150);

connecting_line(2,:) = pchip([line_end(1,:) scatter_point(1)], [line_end(2,:) scatter_point(2)], connecting_line(1,:));

plot(connecting_line(1,:), connecting_line(2,:),'r', 'LineWidth',2);

title('Using ‘pchip’')

xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

How can I connect the upper endpoint of the red curve to the red do... (8)

figure

set(0,'DefaultAxesFontSize',20);

load('BT_Hom(2).mat')

[~,idx] = max(x(326,:));

plot(x(326,1:idx-20),x(325,1:idx-20),'r', 'LineWidth',2);

hold on

axis([0.14 .18 .15 .18]);

scatter(0.174701,0.177614, 'o', 'MarkerFaceColor', 'r');

% line_end = [x(326,idx-20),x(325,idx-20)];

line_end = [x(326,idx-21:idx-20);x(325,idx-21:idx-20)];

scatter_point = [0.174701,0.17761];

connecting_line(1,:) = linspace(line_end(1), scatter_point(1), 150);

connecting_line(2,:) = makima([line_end(1,:) scatter_point(1)], [line_end(2,:) scatter_point(2)], connecting_line(1,:));

plot(connecting_line(1,:), connecting_line(2,:),'r', 'LineWidth',2);

title('Using ‘makima’')

xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

How can I connect the upper endpoint of the red curve to the red do... (9)

figure

set(0,'DefaultAxesFontSize',20);

load('BT_Hom(2).mat')

[~,idx] = max(x(326,:));

plot(x(326,1:idx-20),x(325,1:idx-20),'r', 'LineWidth',2);

hold on

axis([0.14 .18 .15 .18]);

scatter(0.174701,0.177614, 'o', 'MarkerFaceColor', 'r');

% line_end = [x(326,idx-20),x(325,idx-20)];

line_end = [x(326,idx-21:idx-20);x(325,idx-21:idx-20)];

scatter_point = [0.174701,0.17761];

connecting_line(1,:) = linspace(line_end(1), scatter_point(1), 150);

connecting_line(2,:) = spline([line_end(1,:) scatter_point(1)], [line_end(2,:) scatter_point(2)], connecting_line(1,:));

plot(connecting_line(1,:), connecting_line(2,:),'r', 'LineWidth',2);

title('Using ‘spline’')

xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k')

How can I connect the upper endpoint of the red curve to the red do... (10)

This uses the last two points of the red line so that the interpolation functions can use that slope information as well. That is straightforward to expand if necessary. The original (and now commented-out) vales for ‘line_end’ used only the last point.

Zoom in on these to see which works best for you.

.

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABGraphics2-D and 3-D PlotsSurfaces, Volumes, and PolygonsSurface and Mesh Plots

Find more on Surface and Mesh Plots in Help Center and File Exchange

Tags

  • plot
  • fiigure

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


How can I connect the upper endpoint of the red curve to the red do... (11)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

Contact your local office

How can I connect the upper endpoint of the red curve to the red do... (2024)

References

Top Articles
Latest Posts
Article information

Author: Zonia Mosciski DO

Last Updated:

Views: 5858

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Zonia Mosciski DO

Birthday: 1996-05-16

Address: Suite 228 919 Deana Ford, Lake Meridithberg, NE 60017-4257

Phone: +2613987384138

Job: Chief Retail Officer

Hobby: Tai chi, Dowsing, Poi, Letterboxing, Watching movies, Video gaming, Singing

Introduction: My name is Zonia Mosciski DO, I am a enchanting, joyous, lovely, successful, hilarious, tender, outstanding person who loves writing and wants to share my knowledge and understanding with you.