Subscript indices must either be real positive integers or logicals?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
%Jason % Vincent
%Lab2.4 %Getting input from user
clc
R=input('Enter value for R(Kilo): ');
C=input('Enter value for Capacitor(micro): ');
L=input('Enter value for Inductor(henry): ');
V=input ('Enter value for voltage: ');
F=input ('Enter value for frequency(kilo): ');
% Convert the value into phasor domain (Series)
w=2*pi*F;
ZR=R-0j;
XC=1/(w*C);
ZC=0-(XC)*1i;
XL=w*L;
ZL=0+(XL)*1i;
% Calculate Total Z and Voltage(Series)
ZT=ZR+ZC+ZL;
VR=(ZR/(ZT))*V;
VC=(ZC/(ZT))*V;
VL=(ZL/(ZT))*V;
Vrmag=abs(VR);
Vrang=angle(VR);
Va=(Vrang/pi)*180;
t = -1/F:0.01*(1/F):1/F;
Vr(t)=((Vrmag/2)*1.414)*sin(w*t+Va);
subplot(2,1,1);
plot(t,Vr(t))
%Displaying Result
fprintf('The voltage for VR is %4.3f V.\n',VR);
fprintf('Vr(t)=%4.2fsin(%4.2ft+%4.2f)\n',(Vrmag/2)*1.414,w,Va);
Answers (3)
Azzi Abdelmalek
on 10 Nov 2012
Edited: Azzi Abdelmalek
on 10 Nov 2012
The problem is in:
t = -1/F:0.01*(1/F):1/F;
Vr(t)= % t is a real number, can't be used as an index
%use instead
Vr=((Vrmag/2)*1.414)*sin(w*t+Va)
Jason Huang
on 10 Nov 2012
0 votes
1 Comment
Azzi Abdelmalek
on 10 Nov 2012
Don't forget to correct
plot(t,Vr)
This question is closed.
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!