Hi Stefan,
I understand that you are trying to implement frequency modulation for beta>0.4 without using the MATLAB in-built function.
Please find the formula and implementation of the frequency modulation :
% Matlab in-built function for Frequency Modulation
% y = fmmod(x,fc,fm,fDev);
% Equation for Frequency Modulation :
% y = A*cos(2*pi*Fc*t + 2*pi*Kf*integral(m(t)dt from 0 to t)) where m(t) is
% the message/input signal.
% Integral of input signal is summation of that signal which is equivalent to cumsum(x)/Fs
integral_x = cumsum(x)/Fs;
y = 1*cos(2*pi*Fc*t + 2*pi*freqdev*integral_x + initial_phase);
To know more about the in-built functions that are implemented in MATLAB, select that function in your code, right click and select "open 'function_name'" as shown :