I am having trouble formatting this loop to increment my variable in a COMSOL linked Matlab Code
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
model.param.set('Porosity', '0.1');
Originally, my value is set at a specific number, anywhere from 0.1 to 1 in increments of 0.1 for now.
However, I would like to be able to output these numbers in one loop, so I would like to increment my variable of porosity and get graphs for all the increments at once.
model.param.set('Porosity', '0.1,0.1,1.0');
I tried something like this, because that is what MATLAB uses for the time increments from Comsol, but I keep running into the same error.
Failed to evaluate expression for parameter Porosity.
Syntax error in expression.
- Expression: 0.1,0.1,1
- Subexpression: ,0.1,1
- Position: 4
Is it even possible to do what I am trying to do, and am I just going about it incorrectly?
Thank you for any help you may give me
0 Commenti
Risposte (1)
Vatsal
il 4 Giu 2024
Hi,
It seems like you are trying to set the ‘Porosity’ parameter to multiple values in a loop and generate graphs for each value. However, the 'model.param.set' function in COMSOL only accepts a single value at a time.The error being encountered is because '0.1,0.1,1.0' is being interpreted as a single value, which is incorrect.
To achieve the goal, a loop in MATLAB can be used to iterate over the desired range of porosity values, setting the parameter, and generating the graph for each one.
Here is an example of how this might be done:
porosity_values = 0.1:0.1:1.0; % Define the range of porosity values
for porosity = porosity_values
model.param.set('Porosity', num2str(porosity)); % Set the porosity value
% Insert code here to solve the model and generate the graph
end
I hope this helps!
0 Commenti
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!