close all; clear all; d=0.50; Sub_NO=(22:1:72)'; %n lambda=d*sqrt(Sub_NO/2); %df=2*(Sub_NO-1); % for between design df=(Sub_NO-1); % for within design crticalT=tinv(0.975,df); %the degree of freedom is (sub_no-1), for within, one detailed %p2= 1-nctcdf(crticalT,df,lambda) % for one tailed the percentage x>criticalT, should be same as the value in the table p2=nctcdf(-crticalT,df,lambda)+ 1-nctcdf(crticalT,df,lambda) % two tailed, should be same as the value using G*Power dz=d/sqrt(2) plot(Sub_NO,p2,'-') hold on %search for the closest value raltive to a prior power %prior_power=0.75; %[c, index] = min(abs(p2-prior_power)); %Sub_NO(index) [Sub_NO,p2] % [Sub_NO,crticalT] % [Sub_NO,lambda]