The value assigned to variable <variable_name> might be unused
显示 更早的评论
hello, I have this function
function TransmissionLineData nphc =3; ngw = 0 ; resis(1) = 0.1379/1000 ;
....
i receive a warning "npch" might be unused. i also use "npch" as a variable in other functions. and that functions give arror. for example;
??? Input argument "nphc" is undefined.
Error in ==> ShortLine at 3 [RAD,GMR,RES] = BundleReduction(nphc,ngw,nb,bsep,rdext,gmr,resis);
Can anyone help me in this, please?
回答(1 个)
Paulo Silva
2011-2-25
nphc is a local variable of that function, it isn't the same one unless you say it is using global npchc in all the functions that use that variable.
Warning!!! The use of global variables isn't recommended, if you want to share data between functions send variables as arguments.
function1(arg1,arg2)
%some code
nphc=1;
function2(arg1,arg2,nphc)
end
function2(arg1,arg2,nphc)
%some code
nphc
end
Although nphc inside function2 isn't the one on function1 it does have the same value because you send it to this function, you can now put values inside it but it won't change the nphc value inside the function1
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!