# MATLAB: How to save different iterations vales for one single variable

iterationsMATLAB

hello everyone
i have this code running and i want to save the every iteration in excel file but i had only managed to save only the last iteration value. i'm trying to get the P3 iterations for year (meain 8760 hours./ one iteration per hour )
how i can save the every iteration result in an excel file.
thank you very much.
function [P3]=WT_output_power(WTno,HourTTF);%Topic: Stochastic model for wind turbine using Weibull distribution% Author: M.Farhan_Sarwar% Date: September/2020% WTno max condition is 2 and HourTTF max condition is 24Vavg=14.6*(1000/3600); % average wind speed velocity m/ssta=9.75*(1000/3600); % standard deviation of windVci=9*(1000/3600); % the cut-in velocity m/sVr=38*(1000/3600); % the rated wind velocity m/sVco=80*(1000/3600); % the rated cut-off velocity m/sP=[2500;2000]; % the max output power of WT1 and WT2 (KW)k=2; % shape parameterc=8.03; % scaling parameterNC=8760;% finding the output power of wind turbine for 24 hrfor i=1:24;F(i)=c*(-log(rand(1)))^(1/k);% generate uniformly distributed random wind velocityif F(i)<=Vci || F(i)>=Vco % || means orP2(i)=0;endif F(i)>Vci && F(i)<VrP2(i)=P(WTno)*(F(i)^3-Vci^3)/(Vr^3-Vci^3); % the output power of WTendif F(i)>VrP2(i)=P(WTno); %the output power of WTend
V(i)=i;endP3=P2(HourTTF)

p3values = zeros(24, 365);HourTTF = 1 : 24;for day = 1 : 365    [P3]=WT_output_power(WTno,HourTTF);    p3values(:,day) = P3;end