function [ndot,mdot] = MassFlow_Ver4(wH2,wN2,in)

% This function calculates the mass and molar flowrates for the chemicals
% in the respective streams based on the given mass fractions/ratio.
% 
% The independent variables for this are
%   wH2  	Hydrogen
%   wN2     Nitrogen

% The required input is given by
%   in      Array containing the flowrate, the ammonia mass fraction and
%           the H2/N2 ratio of the stream

% Import of CASADI
import casadi.*

% Calculation of the mass fractions of the streams
if isa(wH2,'casadi.MX')
    m = MX.zeros(3,numel(wH2));
else
    m = zeros(3,numel(wH2));
end
m(1,:) = wH2';
m(2,:) = wN2'; 
m(3,:) = 1-wH2'-wN2'; 

% Calculation of the mass and molar flow of the streams
mdot = m.*(ones(3,1)*in(1,:));
ndot = mdot./([2 28 17]'*ones(1,numel(wH2)));
A = 0;