The value assigned to variable <variable_name> might be unused
Ältere Kommentare anzeigen
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?
Antworten (1)
Paulo Silva
am 25 Feb. 2011
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
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!