if/elseif script problem
Mostra commenti meno recenti
Hi there,
I am writing a function designed to take an input note, and return the relevant frequency. However, I keep hitting problems whenever I change the strings slightly.
Here is part of my example that works:
function [f]=note_to_freq(notename)
if notename == 'A'
f=110;
elseif notename == 'A#'
f=116;
....etc
end
Now, when I do something like change the elseif notename == 'A#2', Matlab seems to treat notename as a string and compare the two. This then returns the error message:
??? Error using ==> eq
Matrix dimensions must agree.
Any explanations for why this is happening/how to fix it?
Thanks in advance.
Craig
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Data Type Identification 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!