Dear all,
I'm working on a 2D PDE in coefficient form. In my model, one of the coefficients is set up by an external matlab function fun(t,x,y) according to:
model.physics('...').feature('...').set('a','1','fun(t,x,y)');
Comsol and Matlab have no trouble finding the function and calling it when running the script. However, I get - RANDOMLY - a crash in my simulation with the following error message:
'com.comsol.nativejni.FlNativeException: Incorrect size of returned vector. 6000 elements were expected, but the returned matrix was 1 x 1
- Function : fun
- Feature : Time-Dependant Solver 1 (sol1/t1)
- Error : Incorrect size of returned vector. 6000 elements were expected, but the returned matrix was 1 x 1'
Here is the script of my function and what I discovered so far.
function out = fun(t,x,y)
for i=1length(x)
out(i) = some-crazy-bullshit-computed-using-(t,x,y);
end
end
I decided to investigate why, it was crashing randomly because of an incorrect size of retuned vector. I first decided to turn the previous function into the most simple function one can create:
function out = fun(t,x,y)
out = x;
end
Still the same problem (restarted COMSOL+Matlab, clear functions, whatever... did not work out)
I then decided to have a look at what was being computed in my function, by saving all the interesting variables into a mat file in order to have a look at it later.
function out = fun(t,x,y)
out = x;
save('error.mat','x','y','t','out');
end
Here is what I found
x = {1}
y = {40}
t = {40}
out = {1}
Still, Comsol is telling me : 'com.comsol.nativejni.FlNativeException: Incorrect size of returned vector. 6000 elements were expected, but the returned matrix was 1 x 1.'
I'm afraid there might be no mistake in here. My function returned one element, because t, x and y were singletons...!
What can I do to get rid of this error message ? Can't find anything on the forum or the documentation about this...
Thanks
Matthieu
I'm working on a 2D PDE in coefficient form. In my model, one of the coefficients is set up by an external matlab function fun(t,x,y) according to:
model.physics('...').feature('...').set('a','1','fun(t,x,y)');
Comsol and Matlab have no trouble finding the function and calling it when running the script. However, I get - RANDOMLY - a crash in my simulation with the following error message:
'com.comsol.nativejni.FlNativeException: Incorrect size of returned vector. 6000 elements were expected, but the returned matrix was 1 x 1
- Function : fun
- Feature : Time-Dependant Solver 1 (sol1/t1)
- Error : Incorrect size of returned vector. 6000 elements were expected, but the returned matrix was 1 x 1'
Here is the script of my function and what I discovered so far.
function out = fun(t,x,y)
for i=1length(x)
out(i) = some-crazy-bullshit-computed-using-(t,x,y);
end
end
I decided to investigate why, it was crashing randomly because of an incorrect size of retuned vector. I first decided to turn the previous function into the most simple function one can create:
function out = fun(t,x,y)
out = x;
end
Still the same problem (restarted COMSOL+Matlab, clear functions, whatever... did not work out)
I then decided to have a look at what was being computed in my function, by saving all the interesting variables into a mat file in order to have a look at it later.
function out = fun(t,x,y)
out = x;
save('error.mat','x','y','t','out');
end
Here is what I found
x = {1}
y = {40}
t = {40}
out = {1}
Still, Comsol is telling me : 'com.comsol.nativejni.FlNativeException: Incorrect size of returned vector. 6000 elements were expected, but the returned matrix was 1 x 1.'
I'm afraid there might be no mistake in here. My function returned one element, because t, x and y were singletons...!
What can I do to get rid of this error message ? Can't find anything on the forum or the documentation about this...
Thanks
Matthieu