MATLAB: How to use the value of L and fprintf function in the ‘syms’

MATLABMATLAB C/C++ Math Librarysystem

%Loss Calculation of a Single Phase Transformer
kva=input('Please Enter the KVA rating of transformer in KVA ');
pf=input('Enter the power factor of transformer ');
f=input('Enter the frequency of the transformer in Hz ');
e=input('Enter the efficiency of transformer in % ');
e=e/100;
If=kva/e;
fprintf('The full load input is %f KW',If);
L=If-kva;
fprintf('\nThe full load loss is %f KW',L);
Ih=((kva*pf)/(2*e));
fprintf('\nThe half load input is %f KW',Ih);
%let the Cu and iron loss can be considered as x and y respectively
syms x y
exp1=('x+y-L');
exp2=('(x/4)+y-(L/2)');
[x,y]=solve(exp1,exp2)
fprintf('The Cu loss of transformer is %f KW', x);
fprintf('The iron loss of transformer is %f KW', y);

Best Answer

You should change
exp1=('x+y-L');
exp2=('(x/4)+y-(L/2)');
to
exp1 = x+y-L;
exp2 = (x/4)+y-(L/2);
You cannot fprintf() a symbolic value, but you can probably fprintf() double(x) and double(y)
Related Question