How do I correctly enter the function f(x,y)=sin​((pi/2)*(x​+y))?

4 ビュー (過去 30 日間)
LEONARD-RAMON DINCA
LEONARD-RAMON DINCA 2020 年 5 月 27 日
コメント済み: madhan ravi 2020 年 5 月 28 日
I need to calculate the value for the function using the blending interpolation reffering to x0=-1, x1=1, y0=-1, y1=1 in point (1/3,1/3).
  3 件のコメント
LEONARD-RAMON DINCA
LEONARD-RAMON DINCA 2020 年 5 月 27 日
Yes Madhan, thanks.
LEONARD-RAMON DINCA
LEONARD-RAMON DINCA 2020 年 5 月 27 日
I need to know how to enter the function, MATLAB is new for me and it gives me trouble figuring out how to correctly insert this into it. Could you please assist?

サインインしてコメントする。

回答 (2 件)

David Hill
David Hill 2020 年 5 月 27 日
f=@(x,y)sin(pi/2*(x+y));
[X,Y]=meshgrid(-1:.2:1);%not sure what step size you are using
a=interp2(X,Y,f(X,Y),1/3,1/3);

madhan ravi
madhan ravi 2020 年 5 月 28 日
編集済み: madhan ravi 2020 年 5 月 28 日
% Option 1
x = [x0,x1];
y = [y0,y1]';
z = sin(pi/2*(x+y));
F = griddedInterpolant({x,y},z);
xq = 1/3;
yq = 1/3;
Interpolated = F({xq,yq})
% option 2
f=@(x,y)sin(pi/2*(x+y));
x0=-1;
x1=1;
y0=-1;
y1=1;
x = [x0,x1];
y = [y0,y1];
[xx,yy] = meshgrid(x,y);
% query points
xq = 1/3;
yq = 1/3;
Interpolated = interp2(xx,yy,f(xx,yy),xq,yq) % Interpolated = interp2(xx,yy,f(xx,yy),xq,yq, 'spline') use the method which suits you the best
  2 件のコメント
LEONARD-RAMON DINCA
LEONARD-RAMON DINCA 2020 年 5 月 28 日
Great stuff in here, one last thing, if I would want to show this in GUI how should I run it? Thanks
madhan ravi
madhan ravi 2020 年 5 月 28 日
Maybe you can try using live script , it’s very intuitive.
P.S: I’m not familiar with GUI myself.

サインインしてコメントする。

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by