eval( MPI_Run( MPI_cc('xbasic'), 2,machines) ) gives me error - matlab

I want to use mpiMatlab for my algorithm,i have problem in INSTALLING AND RUNNING of it.
According to this link can any one help me:
http://www.ll.mit.edu/mission/isr/matlabmpi/matlabmpi.html
when i wrote this command in matlab:
eval( MPI_Run( MPI_cc('xbasic'), 2,machines) );
It gives me this error:
??? Undefined function or
method 'MPI_cc' for input
arguments of type 'char'.
Error in ==> Untitled at 1
eval( MPI_Run(
MPI_cc('xbasic'), 2,machines)
);

The error messages suggests that the source code folder is not defined in your MATLABPATH.
Try
which MPI_cc
To see if you can see the code.
Then try to walk before you run.
Does this work?
eval( MPI_Run('xbasic', 2,machines) );
Next does this work?
MPI_cc('xbasic');
Once all these steps are working then you can try your original code.
eval( MPI_Run( MPI_cc('xbasic'), 2,machines) );

Related

Why histeq in Matlab is not working

I want equalize an image histogram. I tried the following code:
I = imread('1.png');
greyI = rgb2gray( I(:,:,1:3) );
J = histeq( greyI );
But the following warning occurred:
??? Attempt to execute SCRIPT histeq as a function:
D:\MatLab Prog\histeq.m
Error in ==> histeq at 3
J = histeq( greyI );
I also tried to get help from about histeq function, but that returns
No help found for histeq.m.
Help from you would be appreciated.
You have created your own file called histeq, see the error message. Delete or rename it to resolve the program.

matlab - suppress error message backtrace

I try to check if input argument is of specific type and throw error message like:
function test(input)
if ~ischar(input)
error('%s is invalid input type.', class(input));
end
end
But Matlab shows error message with backtrace-information:
>> test(1)
Error using test (line 3)
double is invalid input type.
How can I turn off the line Error using test (line 3)?
I'm looking for something similar to off backtrace with warning: warning off backtrace;.
I'm not sure you can. The closest I got was by defining my own error structure:
testerr.message = 'test';
testerr.identifier = '';
testerr.stack.file = '';
testerr.stack.name = 'Test Thing';
testerr.stack.line = 1;
error(testerr)
Which returns:
Error using Test Thing
test
As long as you keep the file field blank it will not display the line specified in the stack.
One potential workaround could be a combination of fprintf and return, courtesy of Undocumented MATLAB:
function test(input)
if ~ischar(input)
fprintf(2, '%s is invalid input type.\n', class(input));
return
end
end
Depending on where this check resides in your real function you might need to get creative with how it exits, since return only kicks you back to the invoking function. Probably have it output a True/False flag?

an error received while executing my function?

When I execute the following:
function [ x ] = addya( varargin )
x=varargin{1};
t=varargin{1};
if(nargin>1)
for i=2:nargin
t=t+varargin(i);
end;
end
x=t;
The error i am getting is:
addya(1,1) ??? Undefined function or method
'addya' for input arguments of type 'double'.
please suggest changes and errors.
Make sure this function is saved in a file called addya.m.
Moreover, as mentioned by il_raffa there's a typo - inside the loop: you should access varargin using {}.
The following code works for me when saved as addya.m:
function [ x ] = addya( varargin )
x=varargin{1}; %// Why is this needed?
t=varargin{1};
if(nargin>1)
for i=2:nargin
t=t+varargin{i};
end;
end
x=t;
Also, I would suggest to refrain from using i as a loop index due to possible complication with complex numbers.

how to use try and catch to print out the unknown error message when calling a function in general in matlab

This is the code
try
** = myfunction( ~ );
catch e
% how shall I do to print out the unknown message ?
end
I encounter this during a project. I already fixed the error. But I was still confused a bit without an answer. So I post it here.
You must decide how to handle the error in the catch. Do you want to simply print out the error message and continue on? If so:
try
** = myfunction( ~ );
catch e
fprintf(1,'ERROR: %s\n', e.message);
end

error in using M block (in Xilinx system generator)?

I wrote this code inside the M Blcok (one of Xilinx blockstes in Simulink):
function z= discorr(x,y)
t=zeros(12288,1);
i=zeros(12288,1);
k=zeros(12288,1);
i(4096:8191,1)=x(1:4096,2); %output of the image filter
t(4096:8191,1)=y(1:4096,2); %output of the tamplate filter
i=i';
z=A(1:4096,1);
for n=1:8191
k=zeros(12288,1);
k(n:n+4095,1)=t(4096:8191,1);
z(n,2)=i*k;
end
end
Its telling me:
Error("discreatcorr.m"): Syntax error: Lexical error at line 15, column 0. Encountered: after : "\';\r\nz=A(1:4096,1);\r\nfor n=1:8191\r\n k=zeros(12288,1);\r\n k(n:n+4095,1)=t(4096:8191,1);\r\n z(n,2)=i*k;\r\n end\r\nend\r\n"
Error("discreatcorr.m"): Syntax error: Lexical error at line 15, column 0. Encountered: after : "\';\r\nz=A(1:4096,1);\r\nfor n=1:8191\r\n k=zeros(12288,1);\r\n k(n:n+4095,1)=t(4096:8191,1);\r\n z(n,2)=i*k;\r\n end\r\nend\r\n"
Error occurred during "Block Configuration".
althogh there is nothing in line 15 in the code
it is giving an error at the end of the code
Any Ideas??
The problem is that your system misinterprets the ' symbol as string symbol. Replacing the line i=i'; by i=transp(i); should solve the problem.