필터 지우기
필터 지우기

Undefined function or variable

조회 수: 3 (최근 30일)
Mira Backes
Mira Backes 2018년 1월 3일
답변: Raul Andres Lopez Romero 2018년 2월 2일
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

답변 (1개)

Raul Andres Lopez Romero
Raul Andres Lopez Romero 2018년 2월 2일
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

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by