Undefined function or variable
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey there,
I'm pretty new to Matlab, but need to use it for some simple calculations. However, I can't seem to make my function work in any way. I've tried several approaches, but nothing seems to get me to where I want.
I'm trying to calculate a coil constant, I need this to be a function, so that I can change all parameters for later use. I seem to have difficulties with the defintion of the function and variables and get the error message " Undefined function or variable ".
I'm not quite sure what to do, and any help would be greatly appreciated.
function s=spolekonstant2(F_n, F_p, F_m, str)
%Formula to find coil constant
%inputs
% F_n is baseline
% F_m is negativ
% str is I, in ampere
% output
% s= coil constant
s = sqrt(((F_p)^2+(F_m)^(2)-2*(F_n)^2)/2*(str)^2);
F_p = 47.925;
F_m = 60.086;
F_n = 50.163;
end
0 Kommentare
Antworten (1)
Raul Andres Lopez Romero
am 2 Feb. 2018
Mira, if you try to make this function that way it does not work, all because the parameters yo use in this function at the end always change, try this: you already create the function like this:
function s=spolekonstant2(F_n, F_p, F_m, str)
%Formula to find coil constant
%inputs
% F_n is baseline
% F_m is negativ
% str is I, in ampere
% output
% s= coil constant
s = sqrt(((F_p)^2+(F_m)^(2)-2*(F_n)^2)/2*(str)^2);
end
So, the only thing you need to do is call the function and fill with the parameters you need,
F_p = 47.925;
F_m = 60.086;
F_n = 50.163;
str=89;
Result=spolekonstant2(F_n,F_p,F_m,str) %this is the way you call the function
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!