Variable integration limits for plotting

Hello, I would like to know how I can set "alpha" as a variable between 0 and 2*pi, and plot "Pload" against "alpha". I have tried to set alpha as linspace(0,2*pi) but the integral requires a scalar for its limits. That is the limit of my knowledge of matlab! I have checked other peoples answers, but can't find the method to fit my specific question.
For those interested, the script is for a simple triac controlling a lamp, where "alpha" is the firing angle of the triac. I have set alpha to pi/3 to obtain the power in the load "Pload" at that specific angle, by want to apply this to all angles from 0 - 2*pi.
Any help appreciated. Chris
Code :
Pbulb = 100;
Vsource = 230;
Vpeak = Vsource*sqrt(2);
T = 2*pi;
alpha = pi/3;
Ifull = Pbulb/Vsource;
Rbulb = Vsource/Ifull;
P = @(x) (((Vpeak*sin(x)).^2)/Rbulb);
Pload = (1/T)*(((integral((P),alpha,(3*alpha))))+(integral((P),(4*alpha),(6*alpha))))

답변 (1개)

the cyclist
the cyclist 2015년 5월 6일
편집: the cyclist 2015년 5월 6일

0 개 추천

Use the linspace command to define the range of possible alpha values, then use a loop to calculate Pload for each value of alpha:
Pbulb = 100;
Vsource = 230;
Vpeak = Vsource*sqrt(2);
T = 2*pi;
alphaRange = linspace(0,2*pi);
numberAlphas = numel(alphaRange);
Pload = zeros(1,numberAlphas);
for na = 1:numberAlphas
alpha = alphaRange(na);
Ifull = Pbulb/Vsource;
Rbulb = Vsource/Ifull;
P = @(x) (((Vpeak*sin(x)).^2)/Rbulb);
Pload(na) = (1/T)*(((integral((P),alpha,(3*alpha))))+(integral((P),(4*alpha),(6*alpha))));
end
figure
plot(alphaRange,Pload)

댓글 수: 2

Fantastic, thank you very much. Now I shall teach myself more about For loops!
Chris
the cyclist
the cyclist 2015년 5월 6일
The best form of thanks is accepting the answer, signifying its usefulness to you (and potentially others).

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

카테고리

도움말 센터File Exchange에서 General Applications에 대해 자세히 알아보기

질문:

2015년 5월 6일

댓글:

2015년 5월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by