Why gridfit is undifined for Matlab 2017b?

조회 수: 8 (최근 30일)
Nima Izadyar
Nima Izadyar 2019년 8월 29일
편집: Walter Roberson 2022년 10월 20일
Hi,
I am trying to run the following code to have uniform input using Matlab R2017b, however, I have received this error 'Undefined function or variable 'grid fit'. I would like to know how I should solve this problem.
Ymin=min(Y); %find minimum Y value
Ymax=max(Y); %find maximum Y value
Ynum=fix((Ymax-Ymin+1)/5); %set number of Y points to use for grid
Hmin=min(H); %find minimum H value
Hmax=max(H); %find maximum H value
Hnum=fix((Hmax-Hmin+1)/5); %set number of H points to use for grid
Ynodes=linspace(Ymin,Ymax,Ynum); %set nodes for the Y direction
Hnodes=linspace(Hmin,Hmax,Hnum); %set nodes for the H direction
[Ygrid,Hgrid]=meshgrid(Ynodes,Hnodes); %create the Y and H grids
[Y,H,z,Ynodes,Hnodes] = gridfit(Y,H,z,Ynodes,Hnodes);
zgrid = [Y,H,z,Ynodes,Hnodes]; %create the zgrid (z for each Y,H)
zgridmin=0; %set the minimum elevation desired
zgridmax=3; %set the maximum elevation desired
[zgridY,zgridH]=size(zgrid); %get the size of the grid
YG = zgridY;
HG = zgridH;
%go through the grid and adjust any points out of desired range
for i=1:YG
for j=1:HG
if zgrid(i,j)<zgridmin
zgrid(i,j)=zgridmin;
end
if zgrid(i,j)>zgridmax
zgrid(i,j)=zgridmax;
end
end
end
L=zgridmax-zgridmin-1;
%create plot with lines at integer values by picking proper number to plot
[C,hh]= contour(Ygrid,Hgrid,zgrid,L);
set(hh,'ShowText','on','TextStep',get(hh,'LevelStep'))

채택된 답변

Walter Roberson
Walter Roberson 2019년 8월 29일
편집: Walter Roberson 2022년 10월 20일
gridfit is not a Mathworks function. It is available in the file exchange.
  댓글 수: 2
John D'Errico
John D'Errico 2019년 8월 29일
As much as I think it SHOULD have been piut into MATLAB in some form, it is not there. But you can always download it again, as you must have done at some point in the past.
Most likely, you still have the code, in some directory that was on your search path for that repvious release. So you just need to update your search path to reflect that.
I always make sure that any downloaded toolboxes (and all of my own toolboxes) get put on the search path when I upgrade a relase. In fact, I even put a code on the file exchange to help you do that.
It allows you to export the current search path of your old release. Then you go into the new release, and then use the import search path tool provided.
yaoxinzheng yaoxinzheng
yaoxinzheng yaoxinzheng 2021년 3월 30일
An error occurred while using the "gridfit" function:
Insufficient data for surface estimation.
What are the possible causes of such errors?
Looking forward to your reply!

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by