How to write function in matlab

조회 수: 4 (최근 30일)
Paul
Paul 2015년 7월 21일
편집: Paul 2015년 8월 11일
Hi all,
Dose any body knows how to write interpolation function (interp2) instead of using its command on matlab?
Best regards,
  댓글 수: 2
Titus Edelhofer
Titus Edelhofer 2015년 7월 21일
Probably yes :). Maybe you explain the purpose of doing so? Fun, homework, missing functionality? Is using interp1 for doing this fine...? etc...?
Titus
John D'Errico
John D'Errico 2015년 7월 21일
There are codes on the file exchange for interpolation. Why not use one of them?
Yes, of course it is possible to write your own interpolation code. But if your goal is to use a home grown code instead of one professionally written, this is a poor choice. And if your goal is to merely learn how to do interpolation, then do some reading. Learn about interpolation methods.
If you have some other obscure reason, then why not tell us? We might be able to offer better advice if we know what you are doing and why.

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

답변 (3개)

Torsten
Torsten 2015년 7월 21일
A starting point :
https://en.wikipedia.org/wiki/Bilinear_interpolation
Best wishes
Torsten.

addou abdeljalil
addou abdeljalil 2015년 7월 21일
m1 =E2(1:4) ; r1 =F2_pixel(1:4) ;
m2 =E2(4:16) ; r2 =F2_pixel(4:16) ;
p1 = polyfit(m1,r1,2) ; % interpolation degre 2
p2 = polyfit(m2,r2,3) ; % interpolation degre 3
y1 = polyval(p1,m1);
y2 = polyval(p2,m2);
plot(E2(1:16),F2(1:16),'o',m1,y1,'r-',m2,y2,'g-')
legend('...');
xlabel ('E2');
ylabel('F2');
title('.......................')
  댓글 수: 1
John D'Errico
John D'Errico 2015년 7월 21일
But this is NOT interpolation. It is NOT a replacement for interp2. Not even close.

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


Alex Taylor
Alex Taylor 2015년 7월 21일
The relevant question that everyone wants to know the answer to is:
What is your reason for needing to know how to solve this problem without using interp2 in MATLAB?
I think if you answer this question, it will help everyone understand what exactly your requirements are for whatever it is you are doing. Unless there is some compelling reason why you don't want to use interp2, everyone is going to suggest using interp2 because you are unlikely to write a faster or more memory efficient 2-D interpolation routine yourself, especially if you are using a recent version of MATLAB.
I have answered a variation of this question in the past on how to do log-polar transformations of images, in your case it looks like you want a polar->cartesian transformation, but the idea is the same. However, in my answer, I used interp2.
  댓글 수: 1
Stephen23
Stephen23 2015년 7월 22일
편집: Stephen23 2015년 7월 22일
What exactly does "interpolation a bit different" mean? Different from what? How should it be different?

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by