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.

Use MATLAB 'for loop' to iterate the boundary loading

Please login with a confirmed email address before reporting spam

Hi I understand changing the last item '2222' in the following code can redifine the boundary loading in terms of pressure: model.physics('solid').feature('bndl1').set('FollowerPressure', '2222'); In my case, I got 13 different values of the boundary pressure and hence I was wondering is there anyway to use MATLAB 'for' loop function to execute all the values at one time? Thanks for your time Best wishes J


1 Reply Last Post 2020年11月5日 GMT-5 07:26
Lars Gregersen COMSOL Employee

Please login with a confirmed email address before reporting spam

Posted: 4 years ago 2020年11月5日 GMT-5 07:26

Hi

Of course there is. Somethis like this:

% load your model using mphopen
values = [22 33 222 333 2222 3333]; % etc.
for i=1:length(values)
  model.physics('solid').feature('bndl1').set('FollowerPressure', values(i));
  model.study('std1').run
  % extract data and make plots
end
-------------------
Lars Gregersen
Comsol Denmark
Hi Of course there is. Somethis like this: % load your model using mphopen values = [22 33 222 333 2222 3333]; % etc. for i=1:length(values) model.physics('solid').feature('bndl1').set('FollowerPressure', values(i)); model.study('std1').run % extract data and make plots end

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.