Note: This discussion is about an older version of the COMSOL Multiphysics® software. The information provided may be out of date.
Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
COMSOL external MATLAB function
Posted Feb 18, 2013, 9:16 a.m. EST Version 4.2 1 Reply
Please login with a confirmed email address before reporting spam
Hello forum.
I want to use an external matlab function to define a local heat transfer coefficient distribution.
If I use a very simple external function, everything works fine:
for example:
function value=alpha(z)
value = ones(size(z))*65000;
end
My function will load an object with the current data from a *mat - file and will read the data and give it back to COMSOL
something like that:
function out=AlphaZ1(z)
global pipe1;
path('V:\30_Numerik\COMSOL\Thermosyphon_2.0alpha\20130218001\classes',path)
strStoredVariableDataFileName = 'V:\30_Numerik\COMSOL\Thermosyphon_2.0alpha\20130218001\pipe1.mat';
load(strStoredVariableDataFileName)
value=pipe1.CondenserSection.GetAlphaZ(z');
out=round(value');
end
Unfortunately I always get an error message:
Attempted to access value(:,1); index out of bounds because size(value)=[0,0].
with no further details
If I save the z - vector to an mat-file and later try to call the function with this z-vector, it works properly and I get the correct heat transfer distribution.
Is there a way to analyse the error message and to find where it occurs? I already tried to catch all errors with a try-catch statement in MATLAB, but that does not help
Matthias
I want to use an external matlab function to define a local heat transfer coefficient distribution.
If I use a very simple external function, everything works fine:
for example:
function value=alpha(z)
value = ones(size(z))*65000;
end
My function will load an object with the current data from a *mat - file and will read the data and give it back to COMSOL
something like that:
function out=AlphaZ1(z)
global pipe1;
path('V:\30_Numerik\COMSOL\Thermosyphon_2.0alpha\20130218001\classes',path)
strStoredVariableDataFileName = 'V:\30_Numerik\COMSOL\Thermosyphon_2.0alpha\20130218001\pipe1.mat';
load(strStoredVariableDataFileName)
value=pipe1.CondenserSection.GetAlphaZ(z');
out=round(value');
end
Unfortunately I always get an error message:
Attempted to access value(:,1); index out of bounds because size(value)=[0,0].
with no further details
If I save the z - vector to an mat-file and later try to call the function with this z-vector, it works properly and I get the correct heat transfer distribution.
Is there a way to analyse the error message and to find where it occurs? I already tried to catch all errors with a try-catch statement in MATLAB, but that does not help
Matthias
1 Reply Last Post Feb 18, 2013, 12:57 p.m. EST