Quantcast
Channel: Latest Discussions - COMSOL Forums
Viewing all articles
Browse latest Browse all 5773

Tuning Fork Bisection Example

$
0
0

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


Viewing all articles
Browse latest Browse all 5773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>