%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % cprod.m - forms the product of a series of complex numbers % numbers and displays the result in both polar and % rectangular format. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% disp(' '); disp(' PROGRAM MULTIPLIES COMPLEX NUMBERS'); disp(' '); disp(' Form: 1-polar, 2-rectangular'); disp(' '); nterms=input('How many numbers to be multiplied? '); disp(' '); for i=1:nterms; F=input(['Form of ',num2str(i),' = ']); if (F~=1 & F~=2); disp('INVALID FORM'); end if F==1 M=input(['Mag ',num2str(i),' = ']); A=input(['Deg ',num2str(i),' = '])*pi/180; N(i)=M*exp(j*A); disp(' '); else R=input(['Real ',num2str(i),' = ']); I=input(['Imag ',num2str(i),' = ']); N(i)=R+j*I; disp(' '); end end P=N(1); for k=2:nterms; P=P*N(k); end disp(' '); disp(['PRODUCT = ' num2str(real(P)) ' +j '... num2str(imag(P)) ' = ' num2str(abs(P)) '|_'... num2str(angle(P)*180/pi) 'deg']);