필터 지우기
필터 지우기

nlinfit using 3D coordinates

조회 수: 1 (최근 30일)
E
E 2013년 4월 9일
Hey guys! I'm trying to figure out this problem:
z(x, y) = A exp [−(((x − B)^2/2*C^2)+ ((y − D)^2/2*E^2))]
I'm given vector data for x,y, and z
So far I have tried using
fxn=@(C,x,y) C(1)*exp (−(((x − C(2))^2/2*C(3)^2)+ ((y − C(4))^2/2*C(5)^2)));
nlinfit(x,z,fxn,[3 3 3 3 3],[],y)
but I'm not sure how to pass the arguments through. HELP!!!
  댓글 수: 1
E
E 2013년 4월 9일
i guess I didn't write it, but I'm trying to fit the data using the given function..The only two things we have learned are polyfit and nlinfit so I know I have to use nlinfit

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

채택된 답변

Tom Lane
Tom Lane 2013년 4월 11일
I like your reasoning for using nlinfit.
I see two issues. First, use ".^" instead of "^" in your expression, because you want elementwise operations rather than matrix operations.
Second, nlinfit wants to call your function with the parameters as the first input and the X variables as the second. You have written a function that takes two different X variables as the second and third inputs. A simple way to deal with that would be to write a little converter:
otherfcn = @(C,xy) fxn(C,xy(:,1),xy(:,2));
nlinfit(x,z,otherfcn,[3 3 3 3 3])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics and Visualization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by