In following plots, how can we measure intersect points?

1 回表示 (過去 30 日間)
MOHD UWAIS
MOHD UWAIS 2023 年 2 月 16 日
回答済み: Kevin Holly 2023 年 2 月 16 日
clear all
clc
for y=0.1:0.1:0.3;
G=[];
B=[];
for a=1:1:100
z=0.3;
x=y+sind(a);
G=[G x];
b=z+0.4;
B=[B b];
end
B;
G;
a=1:1:100;
plot(a,G,'-')
hold on
plot(a,B,'-')
end

採用された回答

Kevin Holly
Kevin Holly 2023 年 2 月 16 日
for y=0.1:0.1:0.3
G=[];
B=[];
for a=1:1:100
z=0.3;
x=y+sind(a);
G=[G x];
b=z+0.4;
B=[B b];
end
B;
G;
a=1:1:100;
plot(a,G,'-')
hold on
plot(a,B,'-')
%spline1
s1 = spline(a,G);
%spline 2
s2=spline(a,B);
% find zeros
a0 = fzero(@(a) (ppval(s1,a)-ppval(s2,a)), 0) %Intersection point using spline interpolation
end
a0 = 36.8699
a0 = 30.0000
a0 = 23.5782

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSplines についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by