Hi,
I do it all the time. it looks like this:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Meep and Matlab by Ehsan Shah Hosseini
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc; clear all; close all; fclose all;
resolution=16;
Q=zeros(100,100);
W=zeros(100,100);
A=zeros(100,100);
E=zeros(100,100);
unix('rm *.h5 *.png *.out *.bak ');
outputname=strcat('cavity.out');
datputname=strcat('cavity.dat');
meepstring=['mpirun -np 8 meep-openmpi fcen=0.33 df=0.07 resolution=',
num2str(resolution), ' d=' , num2str(d)];
meepstring=[meepstring, ' cavity.ctl > ' ];
unix([meepstring, outputname]);
unix(['h5topng -RZc dkbluered -C
cavity-eps-000000.00.h5 cavity-hz-*.h5']);
unix(['convert cavity*.png ',outputname,'.gif']);
replaceinfile('harminv0:, frequency, imag. freq., Q, |amp|,
amplitude, error', '', outputname);
unix(['grep harminv0: ', outputname, ' > ', datputname]);
replaceinfile(',', '', datputname);
fid = fopen(datputname);
tline = fgets(fid);
count=0;
while ischar(tline)
disp(tline);
tline = fgets(fid);
count=count+1;
end
fclose(fid);
fid = fopen(datputname);
resnum=count;
ResQ=1;
if resnum>0
for u=1:resnum
character = fscanf(fid,'%s',1);
while 0 == strcmp('harminv0:',character),
character = fscanf(fid,'%s',1);
end
W(1,u)=fscanf( fid ,'%g',1);
fscanf( fid ,'%g',1)
Q(1,u)=fscanf( fid ,'%g',1);
A(1,u)=fscanf( fid ,'%g',1);
fscanf( fid ,'%g',1)
E(1,u)=fscanf( fid ,'%g',1);
end
end
On 5/23/2011 7:40 PM, neal skinner wrote:
I do it with Octave under Ubuntu all the time. I have never tried this
with Matlab, but Octave is "mostly compatible" with Matlab, so there
is a good probability that this or something similar will work .
cmd = strcat('meep h=',num2str(height),' s=',num2str(sqr),'
argrid.ctl'); %build a command line string including run time parameters
system (cmd); %issue the command to meep
reffilename = 'argrid-refhist.h5'; %read the result into Octave
Good Luck!
Neal
On Mon, May 23, 2011 at 12:53 PM, Marco Zocca <[email protected]
<mailto:[email protected]>> wrote:
Hi all,
has anyone managed to call MEEP from MATLAB? e.g with the
system(['meep' meep_params meep_ctl_file]) , and to process its
output?
I cannot seemingly get MATLAB to wait until the WHOLE output from
MEEP is ready (specifically, until the flux data is output to stdout).
Does anyone know a workaround?
Thanks in advance,
Marco Zocca
_______________________________________________
meep-discuss mailing list
[email protected] <mailto:[email protected]>
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss
--
Ehsan S. Hosseini,
Photonic Microsystems Group, MIT 26-344
cell: 404.290.9198
office: 617.253.3074
_______________________________________________
meep-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/meep-discuss