You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: chisquare_inv.m
    path of file: ./repos/acycle/code/package/wavelet
    
    the code of the file until where you have to start completion: function X = chisquare_inv(P,V);

    
function X = chisquare_inv(P,V);
%CHISQUARE_INV  Inverse of chi-square cumulative distribution function (cdf).
%
%   X = chisquare_inv(P,V) returns the inverse of chi-square cdf with V
%   degrees of freedom at fraction P.
%   This means that P*100 percent of the distribution lies between 0 and X.
%
%   To check, the answer should satisfy:   P==gammainc(X/2,V/2)

% Uses FMIN and CHISQUARE_SOLVE
%
% Written January 1998 by C. Torrence

	if (nargin < 2), error('Must input both P and V');, end