I have a set of values P and D :
P = [175.2582 150.9053 103.9622 69.9965 48.6696]
D = [0 31.3300 61.3200 91.3800 121.4000]
and i want to use the following equation to find a and b
D = a * (P- b)^2
but I have to satisfy the following conditions
if P <= b then D=a * (P- b)^2
else D=0
How can i do this and fit the data?

 채택된 답변

Matt J
Matt J 2021년 3월 20일
편집: Matt J 2021년 3월 20일

1 개 추천

Using fminspleas from the File Exchange,
P = flip([175.2582 150.9053 103.9622 69.9965 48.6696]).';
D = flip([0 31.3300 61.3200 91.3800 121.4000]).';
funlist={@(b,P) (P<=b).*(P-b).^2};
[b,a]=fminspleas(funlist,P(end), P,D),
b = 230.0623
a = 0.0037
fn=@(P) a*funlist{1}(b,P); %fitted function
plot(P,D,'x',P,fn(P));

댓글 수: 1

Moza Salem
Moza Salem 2021년 3월 20일
편집: Moza Salem 2021년 3월 20일
Thank you very much !!! without your help I wouldn't be able to get my beam imprint

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

추가 답변 (0개)

카테고리

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

질문:

2021년 3월 20일

편집:

2021년 3월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by