runtime error in bundle adjustment example - matlab - matlab

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.

Related

"Invalid argument at position 1" error in Matlab and Simulink

I'm coding an RL environment using Matlab and simulink and I'm following the code set out in the following example from mathworks (https://uk.mathworks.com/help/reinforcement-learning/ug/create-simulink-environment-and-train-agent.html)
However for some reason when I'm defining my 'featureInputLayer' I keep getting an error stating that there is an invalid argument at position 1. I'm not certain on what this means, I've seen a few other questions asked here on similar topics but haven't been able to find an answer.
Here's the code where I'm getting an error (the featureInputLayer of StatePath):
statePath = [
featureInputLayer(numObservations,'Normalization','none','Name','State')
fullyConnectedLayer(50,'Name','CriticStateFC1')
reluLayer('Name','CriticRelu1')
fullyConnectedLayer(25,'Name','CriticStateFC2')];
actionPath = [
featureInputLayer(numActions,'Normalization','none','Name','Action')
fullyConnectedLayer(25,'Name','CriticActionFC1')];
commonPath = [
additionLayer(2,'Name','add')
reluLayer('Name','CriticCommonRelu')
fullyConnectedLayer(1,'Name','CriticOutput')];
Any help would be greatly appreciated :D

How can I run createOptimProblem in matlab?

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

What is mean of 'Undefined function 'tfest' for input arguments of type 'idfrd'.'

When I tried to get transfer function from the data, it always returns this information, my friend is able to get result with Matlab 2012 (mine is 2011b). my code is as follow:
load CP.dat
f=CP(:,1)
gain=CP(:,2)
phase=CP(:,3)
gainn=10.^(gain/20)
response=gainn.*exp(1i*phase)
w=f*2*pi
g=idfrd(response,w,0)
sys=tfest(g,3)
The tfest function was introduced into the R2012a version of MATLAB. See the release notes of its toolbox; look at the R2012a New feature section.

Matlab assignment - return only odd elements

I wrote code similar to that posted by FeliceM, but when I tried to include the recommended changes/additions I got the following error:
Warning: File: odd_index.m Line: 5 Column: 18
Function with duplicate name "odd_index" cannot be called.
Here's my code:
function odd_index
M=[1:5; 6:10; 11:15; 16:20; 21:25];
M=M(1:2:end, 1:2:end);
end
function M_out = odd_index(M)
M_out = M(1:2:end, 1:2:end);
end
Not quite sure what I'm doing wrong.
It appears to be simply a problem of naming your two functions the same name. Rename the second function (and make sure it's in a separate file with the same name as itself). Really, the first one isn't a function at all, but appears to be a script.
You may want to refer to the MATLAB Getting Started help documentation for more information on functions and scripts. http://www.mathworks.com/help/matlab/getting-started-with-matlab.html

Publishing function with example of application

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))