Converting an old Matlab code from 2011 to work with newest version
Mostra commenti meno recenti
Hello all
I have very limited Matlab skills as I have used it just couple of times in some courses and mainly for running some premade code. Now however, our paths crossed again and this time for personal hobby project. I am in progress of building a xylophone/marimba for my kid, who has shown some interest in musical instruments. There is a remarkably good xylophone building blog post that I have been reading, which goes through the project in great detail. This blog mentions a Master’s thesis project that focuses on calculating the shape of the curved under side for each bar so that they will produce harmonic timbre. The blog doesn’t include the code itself, but guides the reader to the thesis, which can be found here. The full code is included in the appendix section. I made a pdf to text conversion for the code, fixed the most obvious conversion errors and some warnings that Matlab gave, but there are some functions that my beginner skills cannot handle. I will post those tricky parts here as it was not good practice to paste the whole project. I would greatly appreciate any help and I hope this would also help others.
I currently have Matlab R2020b installed on my work computer, but I can update it to R2022b once I will be back in uni network in early January.
Zhao Mingming's Master's thesis: Automatic Multi Modal Tuning of Idiophone Bars
The pdf to text converted code is in the attachments
The first tricky part is on the page 125 of the thesis, in while loop that begins from the previous page
while any(abs(df)>tol)
%displys the resulted natural frequencies
frequency_old=eval([method'(profile,coeffs,E,G,rho,x_section,nu,d0,width,bar_length,number_of_elements,tol,number_fn,ploton)']);
slope=[];
%for the first three natural frequencies
for k=1:3
coeffs_new=coeffs;
coeffs_new(k)=coeffs_new(k).*delta_a;
frequency_new=eval([method'(profile,coeffs_new,E,G,rho,x_section,nu,d0,width,bar_length,number_of_elements,tol,number_fn,ploton)'])
slope=[slope (frequency_new-frequency_old)./(coeffs_new(k)-coeffs(k))];
end
df=frequency_required-frequency_old;
da=(slope)\df;
coeffs=coeffs+da;
end
I get the following error. I have tried to fix it myself, but no luck so far. This eval([method... appears many times in the program so I think it will get me going if I know how to fix it.
frequency_old=eval([method'(profile,coeffs,E,G,rho,x_section,nu,d0,width,bar_length,number_of_elements,tol,number_fn,ploton)']);
↑
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Debugging and Improving Code in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!