Change
if omega<2.1;
Mg=0;
else
Mg=4.35*10^6*(omega-2.1);
end
to
Mg = zeros(size(omega));
omega_boundary = 2.1;
mask = omega >= omega_boundary;
Mg(mask) = 4.35*10^6*(omega(mask) - omega_boundary);
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!