Intercept of each line to y-line
3 views (last 30 days)
Show older comments
Hello folks,
I am making curve fit plot for some data and trying to make intercept point of each data line with y-line.
For examples. each line should give intercept point so there will be 10 intercept points which can be stored in any array.
I am concerning only x-axis value in the x-yline(1.5228, '--') intercept values. I tried with intercept commands but the problem is here I am dealing with objects.
I am share here code. please have a look and help in this regard, so that when I run a code it will provides x-y intercept values.
clear
close all
Data=[
0.11 0.3 0.28 0.6 0.31
0.23 0.78 0.57 1.08 0.43
0.26 0.95 0.84 1.25 0.46
0.55 1.2 1.1 1.5 0.75
6.95 7.05 8.25 7.35 7.15
5.2 4.34 4.68 4.64 5.4
4.81 4.74 4.21 5.04 5.01
3.96 4.07 3.96 4.37 4.16
3.88 3.78 3.25 4.08 4.08
2.69 2.4 2.81 2.7 2.89
2.36 2.35 2.7 2.65 2.56
2.24 2.28 2.35 2.58 2.44
1.9 2.07 1.94 2.37 2.1
1.7 1.95 1.68 2.25 1.9
0.57 1.67 1.47 1.97 0.77
0.47 0.89 1.1 1.19 0.67
];
figure(1)
plot(Data,'linewidth',1.0)
grid
legend('C1','C2','C3','C4','C5')
x=0:15;
x=x';
c1=Data(:,1);
c2=Data(:,2);
c3=Data(:,3);
c4=Data(:,4);
c5=Data(:,5);
f1 = fit(x(5:16),c1(5:16),'exp1');
f2 = fit(x(5:16),c2(5:16),'exp1');
f3 = fit(x(5:16),c3(5:16),'exp1');
f4 = fit(x(5:16),c4(5:16),'exp1');
f5 = fit(x(5:16),c5(5:16),'exp1');
figure(2)
plot(f1,'b')
hold on
plot(f2,'r')
plot(f3,'g')
plot(f4,'m')
plot(f5,'k')
yline(1.5228, '--')
grid
axis([0 17 0 7.5])
legend('C1','C2','C3','C4','C5')
Thank you.
2 Comments
Accepted Answer
More Answers (1)
DGM
on 20 Feb 2022
Edited: DGM
on 20 Feb 2022
Consider the example:
Data=[
0.11 0.3 0.28 0.6 0.31
0.23 0.78 0.57 1.08 0.43
0.26 0.95 0.84 1.25 0.46
0.55 1.2 1.1 1.5 0.75
6.95 7.05 8.25 7.35 7.15
5.2 4.34 4.68 4.64 5.4
4.81 4.74 4.21 5.04 5.01
3.96 4.07 3.96 4.37 4.16
3.88 3.78 3.25 4.08 4.08
2.69 2.4 2.81 2.7 2.89
2.36 2.35 2.7 2.65 2.56
2.24 2.28 2.35 2.58 2.44
1.9 2.07 1.94 2.37 2.1
1.7 1.95 1.68 2.25 1.9
0.57 1.67 1.47 1.97 0.77
0.47 0.89 1.1 1.19 0.67
];
ymark = 1.5228; % need to be able to use this
x = (0:15).';
plotcolors = {'b','r','g','m','k'};
f = cell(size(Data,2),1);
fk = zeros(size(Data,2),2);
for kn = 1:numel(f)
f{kn} = fit(x(5:16),Data(5:16,kn),'exp1');
fk(kn,:) = coeffvalues(f{kn});
plot(f{kn},plotcolors{kn})
hold on
end
yline(ymark, '--');
grid
axis([0 17 0 7.5])
intx = log(ymark./fk(:,1))./fk(:,2); % inverse of fit function
plot(intx,ymark,'kx') % show with marker
legend('C1','C2','C3','C4','C5')
0 Comments
See Also
Categories
Find more on Descriptive Statistics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!