3- This question deals with creating Matlab functions and making function calls.
ID: 3733808 • Letter: 3
Question
3- This question deals with creating Matlab functions and making function calls. Write a Matlab function and call it MyPower to do the following: A- Create the function (this question may take some time -do your research.) Given the complex current and complex voltage, the function calculates the real power, reactive power, the complex power and the power factor. ar ) Save the function B- Function Call Write a Matlab code to do the following steps: a- b- c make the function call to a function you developed to perform the calculations ddisplay the returned data (clearly) Use correct units C-Explanation / Answer
Matlab program:
prompt1 = 'real part of voltage = ';
prompt2 = 'Imaginary part of voltage = ';
prompt3 = 'real part of current = ';
prompt4 = 'Imaginary part of current = ';
Vreal = input(prompt1);
Vimg = input(prompt2);
Ireal = input(prompt3);
Iimg = input(prompt4);
V = complex(Vreal,Vimg);
I = complex(Ireal,Iimg);
S = V*I;
fprintf(' ');
fprintf('RESULTS: ');
fprintf('Voltage = %d + j %d ',Vreal,Vimg);
fprintf('Current = %d + j %d ',Ireal,Iimg);
fprintf('S = Apparent power = %d + j %d ',real(S),imag(S));
fprintf('P = True power = %d ',real(S));
fprintf('Q = Reactive power = %d ',imag(S));
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.