144 字
1 分钟
CMSOL在Matlab中代码使用
不要在matlab中直接创建plot等表格,应在COMSOL中创建然后在Matlab中调用。
如下所示:
1model.result.export('plot1').set('plotgroup', 'pg3');2 model.result.export('plot1').set('filename', filename);3 model.result.export('plot1').run;1images = xlsread("..\PycharmProjects\set_data\integrated_images\0.xlsx", 'images');2images = reshape(images, [100, 50, 50]);3soil_parameters = xlsread('..\PycharmProjects\set_data\integrated_images\0.xlsx', 'soil_parameters');4model = mphload("topology.mph");5for i = 1:1006 tic7 i;8 graphic = reshape(images(i, :,:), [50, 50]);9 Es = soil_parameters(i, 1)*1e6;10 Ps = soil_parameters(i, 2);11 rhos = soil_parameters(i, 3)*1e3;12 cell = [];13 flag = 1;14 for row = 1:5015 for col = 1:5016 if graphic(row, col) == 117 cell(flag) = 50*(row-1)+col;18 end19 end20 end21 model.param.set('Es', num2str(Es));22 model.param.set('Ps', num2str(Ps));23 model.param.set('rhos', num2str(rhos));24
25 model.component('comp1').physics('solid').feature('lemm2').selection.set(cell);26 model.study('std1').run;27
28 %model.result.create('pg2', 'PlotGroup1D');29 %model.result('pg2').run;30 %model.result('pg2').create('glob1', 'Global');31 %model.result('pg2').feature('glob1').set('markerpos', 'datapoints');32 %model.result('pg2').feature('glob1').set('linewidth', 'preference');33 %model.result('pg2').feature('glob1').set('data', 'dset2');34 %model.result('pg2').feature('glob1').set('expr', {'solid.freq'});35 %model.result('pg2').feature('glob1').set('descr', {[native2unicode(hex2dec({'98' '91'}), 'unicode') native2unicode(hex2dec({'73' '87'}), 'unicode') ]});36 %model.result('pg2').feature('glob1').set('unit', {'Hz'});37 %model.result('pg2').feature('glob1').set('xdatasolnumtype', 'outer');38 %model.result('pg2').run;39 %model.result.export.create('plot1', 'Plot');40 %model.result.export('plot1').set('plotgroup', 'pg2');41
42 model.result.export('plot1').set('filename', ['dispersion_curves/t',num2str(i),'.csv']);43 model.result.export('plot1').run;44 model.hist.disable;45 toc46end部分信息可能已经过时