how i can limit the resistance(R) value within 1000 and 2000 ?

t = 0:0.0001:0.07;
v0 = input('please Enter the value for v0:');
R = input('please Enter the value for resistance:');
C = input('please Enter the value for capacitacne:');
f = input('please Enter the value for frequency:');
m = length(t);
state = 'on';
for A = 1:m
vs(A) = v0 * sin(2*pi*f*t(A));
switch state
case 'on'
vR(A) = vs(A);
iR = vR(A)/R;
iC = 2*pi*f*C*v0*cos(2*pi*f*t(A));
I = iC + iR;
if I<=0
state = 'off';
tA = t(A);
end
case 'off'
vR(A) = v0*sin(2*pi*f*tA)*exp(-(t(A)-tA)/(R * C));
if vs(A) >= vR(A)
state = 'on';
end
end
end
plot (t,vs,':',t,vR,'k')
thanks...

댓글 수: 4

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 16일
편집: Azzi Abdelmalek 2013년 9월 16일
Amir, why have you deleted your question? please restore it.
hey bro,sorry bcs of deleting. Actually this question was a part of my assignment and i cannot keep it here bcd my university will use plagiarism checker to check my assignment.
This forum is not for plagiat
okay bro,i restored them...

댓글을 달려면 로그인하십시오.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 15일
Change the line
R = input('please Enter the value for resistance:');
by
R=0
while R<=1000 | R>=2000
R = input('please Enter the value for resistance: 1000<=R<=2000');
end

추가 답변 (0개)

카테고리

태그

아직 태그를 입력하지 않았습니다.

질문:

2013년 9월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by