"i want to change mean voltage with respect to frequency" - Could you clearly elaborate on what should be the dependance of frequency in mean voltage calculation.
As per the above code, the mean value k changes if the frequency f is changed. Other workaround might be to incorporate the frequency parameter in calculating v as illustrated below:
where func(f) represents the dependance of frequency in calculating the voltage.
If this isn't the issue you were facing, could you mention the exact problem you want to resolve.