⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 existfile.c

📁 This contribution provides functions for finding an optimum parameter set using the evolutionary alg
💻 C
字号:
#include <mex.h>
#include <matrix.h>
#include <stdio.h>

/* res = existfile(filename) */

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
	mxArray *resultArray;
	int result = 0;
	char filename[500];
	FILE *fid;
	
	if (nrhs > 0)
	{
		mxGetString(prhs[0], filename, 498);
		fid = fopen(filename, "r");
		if (fid == NULL )
		{
			/* file does not exist */
			result = 0;
		}
		else
		{
			/* file exists */
			result = 1;
			fclose(fid);
		}
	}
	else
	{
		result = 0;
	}
	resultArray = mxCreateDoubleScalar(result);
	
	plhs[0] = resultArray;
	nlhs = 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -