I need help fixing MATLAB issues as it says not enough input arguments - matlab

I am trying out a project https://github.com/janstenum/GaitAnalysis-PoseEstimation and when I run the command correctLegID_openpose.m as said in the documentation, I get this error
Not enough input arguments.
Error in correctLegID_openpose (line 3)
file = sprintf('%s%s',output_name,'_openpose.mat');
Error in run (line 91)
evalin('caller', strcat(script, ';'));
I tried running the command normally by using
run("correctLegID_openpose.m")

run() is for scripts, not for functions that take arguments. If correctLegID_openpose.m is on your Matlab search path, you can just call it directly and supply the missing input argument:
output_name = 'filename';
correctLegID_openpose(output_name)

Related

For MATLAB mirfeatures function I get the valid interpreter syntax error

Following this manual page 195, I run the f = mirfeatures(a), where a is a miraudio('mysong.wav') object. Then I want to get the results stored in f. However, I get the following error after this command: f.dynamics.rms{1}
Brace indexing is not supported for variables of this type.
and the following warning after this command: f.dynamics.rms
Warning: Error updating Text.
String scalar or character vector must have valid interpreter syntax:
RMS energy, E:\Video-Project\Watches\audio_320k_44100_1122002.wav
> In defaulterrorcallback (line 12)
In mirscalar/display_figure (line 390)
In mirscalar/display (line 10)
I need to mention that when I run mirrms(a). I get no warning. The mentioned commands are on the manual page 195.
Also. f.dynamics.rms generates a figure.
Here is the code and the audio file:
a = miraudio('audio_320k_44100_1122002.wav');
f = mirfeatures(a);
f.dynamics.rms;
f.dynamics.rms{1};

Print a MATLAB figure to a specific directory

I'm using MATLAB version R2016a on a Mac and I'm having trouble printing a figure to a different directory than the current one. Could someone please help me fix my mistake? I have tried the following code:
print('Ult_Stress_vs_Temp','-dpng','/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/')
Can someone tell me what I'm doing wrong?
When I run this I get the following error:
Error using inputcheck (line 40)
Multiple inputs that look like file names: 'Ult_Stress_vs_Temp' and
'/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/'.
Error in print (line 41)
[pj, devices, options ] = inputcheck( pj, inputargs{:} );
Error in ult_stress_temp_plot (line 47)
print('Ult_Stress_vs_Temp','-dpng','/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/')
>>
You need to specify the full file path as the first argument. It's also recommended that you construct your file paths using fullfile to better deal with differences between operating systems.
filename = fullfile('/Users/Tim/Documents/2-Grad-School/Research/Technical-Paper/Latex/Figures/', 'Ult_Stress_vs_Temp');
print(filename, '-dpng')

How can I load a text file in a specific variable using matlab/Octave?

I want to load train.txt in to a variable named train_org.
But, the following is generating an error?
>> train_org = load train.txt;
parse error:
syntax error
>>> train_org = load train.txt;
^
How can I fix that?
N.B. The text file loads perfectly without that variable name.
You are getting a syntax error because you are using the command syntax to call the load function and you can't assign the output to a variable this way.
Command syntax does not allow you to obtain any values that might be returned by the function. Attempting to assign output from the function to a variable using command syntax generates an error. Use function syntax instead.
You need to use the standard function syntax instead.
train_org = load('train.txt')

Unexpected matlab expression in function

I have the following call to a function:
callfun(I1, I2, [X Y ones(n,1)], w, m)
But, I'm getting:
Error: File: callfun.m Line: 20 Column: 3
Unexpected MATLAB expression.
Why is that?
Thanks.
The error says, that your function callfun has a syntax error in line 20. Probably some character which is not allowed.
It can be also a problem of duplicated function definition. A function inside callfun.m may have the same name as a built-in MATLAB function, what yields an error.
From http://www.mathworks.com/matlabcentral/answers/214993-how-to-solve-error-unexpected-matlab-expression-workspacefunc-287:
Do you have any user-defined functions called builtin, strjoin, or strsplit? MATLAB has these defined internally, and having any outside functions that shadow these built-in ones would result in this error. If you are unsure if you have created such functions, typing the command:
>>which functionName -all
will show you the path to all items on the MATLAB path with the name "functionName"

Octave : Index exceeds matrix dimensions

I wrote the following function in a file named conditionals.m:
function result = conditionals(category, feature)
result=5;
end
I call this function from Octave's command line:
v=conditionals(3,4)
I get the following error:
error : A(I) : Index exceeds matrix dimension.
Whats wrong here?
The error:
error : A(I) : Index exceeds matrix dimension.
Indicates that octave thinks that conditionals is a matrix, not a function.
Octave probably doesn't know that conditionals is a function - and instead it's treating it as a matrix.
Have you checked to see if the function is in Octave's search path?
This works for me.
octave> function result = conditionals (category, feature)
> result = 5;
> endfunction
octave> v = conditionals (3, 4)
v = 5
The error suggests that you have a variable with the same name as the function. Type whos at the Octave prompt to see a list of defined variables. If you see one named conditionals, remove it with clear conditionals
Also, if conditionals is a conditionals.m file, make sure it's on the function search path. Run path at the Octave prompt to see the function search path. Run which conditionals at the command prompt to see where the function is located.
It happened to me as well and it can happen on any command, regardless of the command name. When I run the PS1(">>"); to change the command prompt in Ovtave, I got the same error.
octave-3.2.3.exe:9> PS1(">>");
error: A(I): Index exceeds matrix dimension.
As others also mentioned, this error fires when there is a parameter with the same command name. It happens when we mistakenly enter the command with wrong syntax and hence, octave run the command and produce a variable with your command name that overload the internal command.
You can verify this status by who command. If you can see the same variable name as your command here, you have to remove it. Use clear variable_name to remove the variable.
Here is my output for PS1 command.
Hope it helps.