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.

Tuning Fork Bisection Example

Sinéad Mannion Plasma Physics

Please login with a confirmed email address before reporting spam

Hiya,

I'm trying to use bisection to find the correct prong length for a tuning fork to give a specific freq eg 400 Hz.

function[optlength,optfreq]=optimize_tuning_fork(model,freq_target)
%simple bisection

disp('****Initial interval****')
%interval = [80 90];
highInt = 90;
lowInt = 80; 
    for i=1:20

int = (highInt+lowInt)/2;

freq_1 = solve(model, int);
%freq_1 = solve(int);
disp(int,freq_1)

if freq_1 < freq_target 
    highInt = int
else
    lowInt = int
end 
end 
optlength = int
optfreq = freq_1


   function freq = solve(model,Lp)
%solve the model for different values of L

disp('Solving model')
Lp
model.param.set('Lp',Lp);
model.study('std1').run;
   freq = mphglobal(model,'freq')

I get the attached error.

Error using disp
Too many input arguements.

Error in optizimse_tuning_fork (line 14)
   display(int, freq)

Any help would be much appreciated...

Thanks, Sinéad



0 Replies Last Post Mar 16, 2020, 12:14 p.m. EDT
COMSOL Moderator

Hello Sinéad Mannion

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.

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.