MATLAB Answers

How to calculate a curve for different variables?

1 view (last 30 days)
I have a function : Current = msx60iScript(V,Suns,Temperature), which is dependant on 3 variables; Voltage, Suns, and Temperature.
As temperature and suns are time dependant functions, I have created 2 vectors which give the temp and irradiance at each time:
Sunrise = -2.1749
Sunset = 11.0372
Time = linspace(Sunrise,Sunset,200)
Temperature = -abs(0.333333333333333.*(Time-5.83))+27.22
Suns = (293.*sin(0.3692.*Time+6.218)+223.6)./1000
I have also created a vector: Voltage as follows:
V = linspace(30,70)
I want to obtain the Voltage v Current data for each time specified above.
-- More info--
I want to obtain the Current v Voltage data for each time in order to calculate the maximum power at each time, and then calculate efficiency.
If anyone has any ideas about how to do this, I would be very grateful.


Sign in to comment.

Accepted Answer

Are Mjaavatten
Are Mjaavatten on 15 Aug 2019
Here is one way to do it. I have reduced the number of elements in your Time and V vectors in order to make a nicer surface plot.
Sunrise = -2.1749;
Sunset = 11.0372;
Time = linspace(Sunrise,Sunset,50);
msx60iScript = @(V,S,T) sin((V-30)/20+2*S)*log(S+5)*T; % Dummy function
V = linspace(30,70,50);
P = zeros(length(Time),length(V));
maxPower = zeros(size(Time));
maxVoltage = zeros(size(Time));
for k = 1:length(Time);
Temperature = -abs(0.333333333333333.*(Time(k)-5.83))+27.22;
Suns = (293.*sin(0.3692.*Time(k)+6.218)+223.6)./1000;
Current = msx60iScript(V,Suns,Temperature); %Must return vector size of V
Power = V.*Current;
[maxPower(k),index] = max(Power);
maxVoltage(k) = V(index);
P(k,:) = Power;
subplot(211);plot(Time,maxPower);xlabel Time;ylabel('Max power')
subplot(212);plot(Time,maxVoltage);xlabel Time;ylabel('Corresponding voltage')
surf(V,Time,P); xlabel Voltage;ylabel Time; zlabel Power;


Sign in to comment.

More Answers (0)




Community Treasure Hunt

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

Start Hunting!