Subscript indices must either be real positive integers or logicals?

%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)

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)
Problem solved! I got my graph!
Thank You!!!1
o(∩_∩)o

This question is closed.

Products

Asked:

on 10 Nov 2012

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!