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.

Extracting Data in Matlab from Comsol

Please login with a confirmed email address before reporting spam

I did an eigenfreqeuncy analysis in Comsol (35.5a) and then saved it as an m file, loaded it in Matlab and then set up a parameter loop (so change the length of my resonator).

How do I extract the information from the simulation? For example I would like to write the eigenfrequencies to a file. I thought the command was

eigfreq_smsld(i)

where i is the solution number, but it doesnt work.

If I use

postmin(fem,'eigfreq_smsld')

I get the first resonance found by the simulation, but I would like all of them!

Thanks for any help.


3 Replies Last Post Feb 11, 2011, 2:58 p.m. EST
Ivar KJELBERG COMSOL Multiphysics(r) fan, retired, former "Senior Expert" at CSEM SA (CH)

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Feb 11, 2011, 2:33 p.m. EST
Hi

here is something I recived and have used some time ago in 3.5a to plot out all eigenfrequencies, not really extracting the data, but youcould perhaps find how to via the embedded postplot() call:

%%%===== start ==============================
%function plot_eigenfrequency(fem,N)

for k=1:length(fem.sol.lambda)
% Plot solution
postplot(fem, ...
'tridata',{'w','cont','internal','unit','m'}, ...
'triedgestyle','none', ...
'trifacestyle','interp', ...
'tribar','on', ...
'trimap','jet(1024)', ...
'deformbnd',{'u','v','w'}, ...
'deformscale','auto', ...
'solnum',k, ...
'phase',0, ...
'title',['eigfreq_smsld' num2str([k,-imag(fem.sol.lambda(k))/2/pi],'(%02i)=%9.5f') ' Boundary: z-displacement [m] Deformation: Displacement [m]'], ...
'refine','auto', ...
'geom','on', ...
'geomnum',[1], ...
'bdl',{[1,2,3,4,5,6]}, ...
'axisvisible','on', ...
'axisequal','on', ...
'grid','on', ...
'camlight','off', ...
'scenelight','off', ...
'campos',[-1.416727900505066E-5,-1.0538846254348755E-5,1.4644881301350798], ...
'camtarget',[-1.416727900505066E-5,-1.0538846254348755E-5,-2.9264017939567566E-5], ...
'camup',[0,1,0], ...
'camva',14.281497848670261, ...
'camprojection','orthographic', ...
'transparency',1.0 );

filename=['_em1f' num2str(k,'_eig%0.2i')];
saveimage(filename);
end

%%%===== end ===============================================

--
Good luck
Ivar
Hi here is something I recived and have used some time ago in 3.5a to plot out all eigenfrequencies, not really extracting the data, but youcould perhaps find how to via the embedded postplot() call: %%%===== start ============================== %function plot_eigenfrequency(fem,N) for k=1:length(fem.sol.lambda) % Plot solution postplot(fem, ... 'tridata',{'w','cont','internal','unit','m'}, ... 'triedgestyle','none', ... 'trifacestyle','interp', ... 'tribar','on', ... 'trimap','jet(1024)', ... 'deformbnd',{'u','v','w'}, ... 'deformscale','auto', ... 'solnum',k, ... 'phase',0, ... 'title',['eigfreq_smsld' num2str([k,-imag(fem.sol.lambda(k))/2/pi],'(%02i)=%9.5f') ' Boundary: z-displacement [m] Deformation: Displacement [m]'], ... 'refine','auto', ... 'geom','on', ... 'geomnum',[1], ... 'bdl',{[1,2,3,4,5,6]}, ... 'axisvisible','on', ... 'axisequal','on', ... 'grid','on', ... 'camlight','off', ... 'scenelight','off', ... 'campos',[-1.416727900505066E-5,-1.0538846254348755E-5,1.4644881301350798], ... 'camtarget',[-1.416727900505066E-5,-1.0538846254348755E-5,-2.9264017939567566E-5], ... 'camup',[0,1,0], ... 'camva',14.281497848670261, ... 'camprojection','orthographic', ... 'transparency',1.0 ); filename=['_em1f' num2str(k,'_eig%0.2i')]; saveimage(filename); end %%%===== end =============================================== -- Good luck Ivar

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Feb 11, 2011, 2:49 p.m. EST
thanks, I'll give it a shot.
thanks, I'll give it a shot.

Please login with a confirmed email address before reporting spam

Posted: 1 decade ago Feb 11, 2011, 2:58 p.m. EST
I found it!
the command for the frequency is:

-imag(fem.sol.lambda(i))/2/pi

where i is the solution number.

thanks again.
I found it! the command for the frequency is: -imag(fem.sol.lambda(i))/2/pi where i is the solution number. thanks again.

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.