I have been trying to publish a function I wrote in matlab. How can I enter variables in order to show the reader that function works with these numbers ? I tried using
publish(passage3([1 2 3 4;2 3 4 5]))
but I got the following messge:
Error in LocateFile elseuf (length(dir(file))==1) Error in publish (line 87) fullPathtoScript=LocateFile(file) Error using passage3 not enough input arguments"
When I activate the function on the same example it works great but about publish... How can I solve that?
Well,I found that the right command for the file func.m is
publish('func.m', struct('codeToEvaluate', 'func(matA,matB,...)', 'showCode', true))
Related
I have created this function :
function Calcul_Constantes ( xBin1 , xTin1 , xHin1 )
% computes global variables that change depending on the circumstances
global v rhoc K1v K2v xBin xTin xHin cBin cTin cHin;
xBin=xBin1;
xTin=xTin1;
xHin=xHin1;
rhoc = 0.02777*(2.106*xHin+78.12*xBin)*(6.935*xHin+23.15*xBin);
K1v=0.6*rhoc/175;
K2v=(2.70803*10^-4+7.5*10^-4*v*rhoc)/175;
cBin=0.02777*xBin;
cTin=0.02777*xTin;
cHin=0.02777*xHin;
end
and when I do test in my main script :
Calcul_Constantes(0,0,1);
xBin
xHin
the following error occures:
Error using Calcul_Constantes
Too many input arguments.
Error in Mercredi15_main (line 48)
Calcul_Constantes(0,0,1);
I'd be grateful for any help, I really can't see what does not work
Probably there is another Calcul_Constantes function somewhere else. You might have saved another version of Calcul_Constantes function somewhere.
In command line type :
which Calcul_Constantes
and check if the return directory and .m file is the which you are trying to use. Rename or delete the wrong function.
I asked it in MATLAB forums but didnt get a response. Hoping someone can answer the question here:
I tried using Bundle Adjustment example at https://www.mathworks.com/help/vision/ref/bundleadjustment.html#inputarg_xyzPoints
However, I get an error: "Error using getPrmDflt (line 47) odd number of parameters in prm Error in bundleAdjustment (line 49) getPrmDflt( varargin,{ 'KMask', [], 'nItr', 500, ..."
at this line: [xyzRefinedPoints,refinedPoses] = bundleAdjustment(xyzPoints,pointTracks,cameraPoses,cameraParams);
After looking more into it the input to getPrmDflt is totally different that what the function expects. Is there some bug or wrong function call in bundle adjustment code?
it was an error from my side. I had downloaded Vincent's MATLAB toolbox a couple of years ago for use and it had a bundleAdjustment function call that overrode the MATLAB function.
My question is a little bit stupid, but still, I would like someone who can help me if he/she face the same problem as me.
I copy the codes directly from MATLAB mathwork:
anonrosen = #(x)(100*(x(2) - x(1)^2)^2 + (1-x(1))^2);
opts = optimoptions(#fmincon,'Algorithm','interior-point');
problem = createOptimProblem('fmincon','x0',randn(2,1),...
'objective',anonrosen,'lb',[-2;-2],'ub',[2;2],'options',opts);
However, it gives the following error message:
Undefined function 'createOptimProblem' for input arguments of type 'optim.options.Fmincon'.
createOptimProblem should be a built-in function, but with the presence of the error message, I wonder if I need to declare sth before using createOptimProblem, what should I do?
I am using R2013a version
I have a code in matlab (~1000 lines) that constists of about 15 functions. The code runs fine with each function as a different script, but I want to put them all into one file so I can use the publish function more easily. However, when I put them all together my 'main' function isn't recognizing the local functions. Here's what it looks like:
function full_function()
...
values = fvalues(0);
...
end
function values = fvalues(state)
...
end
When I try to run it, it gives me
"Undefined function 'fvalues' for input arguments
of type 'double'.
Error in full_function (line 32)
values = fvalues(0);"
I've looked all over for how to do local functions and I have no idea what I'm doing wrong. If I right-click on fvalues and hit 'open' it even brings me to the correct portion of the code, so I have no idea why full_function cannot read it. Please help! Thanks.
I am trying to calculate the covariance matrix in my code but I am getting an error doing that. I have the array of mean values which I want to use. Here is my code
Mat Zt(Z);
Mat Zttranspose;
Mat covarZ=cvCreateMat(image->nChannels,image->nChannels,CV_32FC1);
Zttranspose=Zt.t();
Mat_<float> arraymean=(Mat_<float>(3,3)<< meanb, meang, meanr);
calcCovarMatrix(Zt,covarZ,arraymean,CV_COVAR_USE_AVG,CV_64F)
But I get the following error:
OpenCV Error: Assertion failed (((flags & CV_COVAR_ROWS) != 0) ^ ((flags & CV_COVAR_COLS) != 0)) in calcCovarMatrix, file /usr/local/src/OpenCV-2.3.0/modules/core/src/matmul.cpp, line 2127 terminate called after throwing an instance of 'cv::Exception'
Mat covarZ=cvCreateMat(..); I think you have mix out with C and C++ API.
You might want to have a look at this link http://pastebin.com/cWQi4ngv.
I have tried and it works.
You're creating the matrix with CV_32FC1 and then calling calcCovarMatrix with CV_64F - you need to make them consistent for starters.
This will solve your problem
-
calcCovarMatrix(Zt,covarZ,arraymean,CV_COVAR_USE_AVG | CV_COVAR_ROWS,CV_64F)