Variable integration limits for plotting
Afficher commentaires plus anciens
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))))
Réponses (1)
the cyclist
le 6 Mai 2015
Modifié(e) : the cyclist
le 6 Mai 2015
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 commentaires
Christopher Lamb
le 6 Mai 2015
the cyclist
le 6 Mai 2015
The best form of thanks is accepting the answer, signifying its usefulness to you (and potentially others).
Catégories
En savoir plus sur General Applications dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!