function doesnt works well
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nurul Ain Basirah Zakaria
am 20 Dez. 2021
Kommentiert: Nurul Ain Basirah Zakaria
am 21 Dez. 2021
Hi, I am using this function;
function [s,tint] = spei(t,prec,pevap,varargin)
But, I am not sure what is varargin works for?
The size of my file are;
t=1x1x420
prec=98x56x420
pevap=98x56x420
Error using spei (line 40)
Expected a string scalar or character vector for the parameter name.
2 Kommentare
Star Strider
am 20 Dez. 2021
It will be necessary to carefully read the documentation for the file to understand what the arguments must be, and what their order must be.
Rik
am 20 Dez. 2021
Function posted in duplicate question:
function [spei_index]=calculate_spei(t,prec,pevap,varargin);
[nlon, nlat, n]=size(prec);
prec=squeeze(prec);
for i=1:nlon
for j=1:nlat
if isnan(prec(i,j,1))==0
spei_index(i,j,:)=spei(t,prec(i,j,:),pevap(i,j,:),varargin);
else
spei_index(i,j,:)=ones(1,n-12)*NaN;
end
end
end
Antworten (2)
Walter Roberson
am 20 Dez. 2021
spei_index(i,j,:) = spei(t, prec(i,j,:), pevap(i,j,:), varargin{:} );
is my guess.
5 Kommentare
Rik
am 20 Dez. 2021
varargin is typically used to capture optional input arguments:
help varargin
Since you don't use the optional/unnamed inputs, there shouldn't be any issues.
The function you're using should have documentation explaining how to use it. Read it. If you don't understand it, please provide a reference to where you got this function (as I can't find it).
2 Kommentare
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!