How can I plot these functions?
조회 수: 1 (최근 30일)
이전 댓글 표시
I am trying to plot the frequency and duty cycle of a 555 timer's output, I have already calculated the equations I am trying to plot but I get an error whenever I try to actually plot them. The x axis needs to be logarithmic, and represents a varying resistor in the 555 timers outer circuitry. It goes from 1k to 100k ohms. Ra is another resistor set to 1k, and c is also constant. Here is my code:
ra = 1000; %constant first resistor
x = 1000:100:100000; %Rb from 1000 to 100,000 in increments of 100
c = .000000047; %constant capacitors capacitance
figure; %creates the plot window
y1 = 1/((ra+x)*c + (x*c)); % 1/T is the frequency
y2 = ((ra+x)*c)/((ra+x)*c + (x*c)) * 100; %duty cycle which is = charge time / T * 100%
semilogx(x,y1);
semilogx(x,y2);
legend('Frequency, Hz','Duty Cycle in %');
xlabel('Rb in Ohms');
title('555 timer graph');
the error that I get is:
>> fiveFiveFive Error using / Matrix dimensions must agree.
Error in fiveFiveFive (line 13) y1 = 1/((ra+x)*c + (x*c)); % 1/T is the frequency
댓글 수: 0
채택된 답변
Mischa Kim
2014년 4월 11일
편집: Mischa Kim
2014년 4월 11일
y1 = 1./((ra+x)*c + (x*c));
y2 = ((ra+x)*c)./((ra+x)*c + (x*c)) * 100;
Notice the period in front of the division operators.
댓글 수: 0
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!