struct to restrict curve in max problem

I have to keep the blue curve for a=1.617915e-01 (black broken line) to a=1.619728e-01. There's a small segment of the curve near the black vertical line that is unwanted. How can I remove it?
clear all
warning off
format long
set(0,'DefaultAxesFontSize',20);
figure;
load('H_LC(1).mat');
dim=2; %number of variables of my system which are x and y
MM=max(x(1:dim:end-2,:));
plot(x(end,:),MM,'b', 'LineWidth',2);
xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
hold on; xline(1.617915e-01,'k--', 'LineWidth',1);
axis([.16175 .1621 .3 1]);

 채택된 답변

Voss
Voss 2024년 6월 7일
warning off
format long
set(0,'DefaultAxesFontSize',20);
figure;
load('H_LC(1).mat');
dim=2; %number of variables of my system which are x and y
MM=max(x(1:dim:end-2,:));
[~,idx] = min(x(end,:));
plot(x(end,1:idx),MM(1:idx),'b', 'LineWidth',2);
xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
hold on; xline(1.617915e-01,'k--', 'LineWidth',1);
axis([.16175 .1621 .3 1]);

댓글 수: 6

Atom
Atom 2024년 6월 7일
편집: Atom 2024년 6월 7일
Hi Voss. Thanks for the post. Could you please provide the code without using min (min(x(end,:))? Instead, use the value a=1.617915×10−1\times 10^{-1} to help me restrict the curve as desired.
warning off
format long
set(0,'DefaultAxesFontSize',20);
figure;
load('H_LC(1).mat');
dim=2; %number of variables of my system which are x and y
MM=max(x(1:dim:end-2,:));
a=0.1617915;
[~,idx] = min(abs(x(end,:)-a)); % index of the element of x(end,:) nearest to a
plot(x(end,1:idx),MM(1:idx),'b', 'LineWidth',2);
xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
hold on; xline(a,'k--', 'LineWidth',1);
axis([.16175 .1621 .3 1]);
Atom
Atom 2024년 6월 7일
편집: Atom 2024년 6월 7일
Thank you. However, I'm having trouble with the second part of the problem. Specifically, I can't handle the lines after load('H_LC(2).mat') in the code below;. I am unable to load H_LC(2).mat because the file size is too large to load. I can explain it better with a figure. In the attached figure '11.jpg', I used the second part of the code to generate it. I also don't want to keep the lower part of the curve that you plotted.
warning off
format long
set(0,'DefaultAxesFontSize',20);
figure;
load('H_LC(1).mat');
dim=2; %number of variables of my system which are x and y
MM=max(x(1:dim:end-2,:));
a=0.1617915;
[~,idx] = min(abs(x(end,:)-a)); % index of the element of x(end,:) nearest to a
plot(x(end,1:idx),MM(1:idx),'b', 'LineWidth',2);
xlabel('$a\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
ylabel('$b\rightarrow$','FontSize',20,'interpreter','latex','FontWeight','normal','Color','k');
hold on; xline(a,'k--', 'LineWidth',1);
axis([.16175 .1621 .3 1]);
hold on
load('H_LC(2).mat');
dim=2; %number of variables of my system which are x and y
MMM=max(x(1:dim:end-2,:));
plot(x(end,:),MMM,'r', 'LineWidth',2); % RED
I guess for H_LC(2).mat you would
load('H_LC(2).mat');
dim=2; %number of variables of my system which are x and y
MMM=max(x(1:dim:end-2,:));
a=0.1617915;
[~,idx] = min(abs(x(end,:)-a)); % index of the element of x(end,:) nearest to a
and then
plot(x(end,idx:end),MMM(idx:end),'r', 'LineWidth',2);
or
plot(x(end,1:idx),MMM(1:idx),'r', 'LineWidth',2);
Atom
Atom 2024년 6월 7일
Thank you so much. I am extremely grateful. Countless thanks.
Voss
Voss 2024년 6월 7일
You're welcome!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Fit Postprocessing에 대해 자세히 알아보기

태그

질문:

2024년 6월 7일

댓글:

2024년 6월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by