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

📄 cst_prs2matlab_m(reserved).cpp

📁 CST格式转MATLAB格式 CST格式转MATLAB格式 CST格式转MATLAB格式
💻 CPP
字号:
/*
该程序读入由CST保存的具有相同顺序的三组数据(prs格式),整合在一个m文件里,
第一列是下标,后面三列分别对应三组数据的幅值
*/
#include<stdio.h> 
#include<stdlib.h>
#define LEN 13
int main(void) 
{ 
		char len_rec[LEN]="000000000000";
        FILE *fp1,*fp2,*fp3,*fpout;                     //定义文件指针
        fp1=fopen("7^probe1(1).prs", "r");
		fp2=fopen("7^probe2(1).prs", "r");
		fp3=fopen("7^probe3(1).prs", "r");
		fpout=fopen("float_in_strip.m", "w");
		fseek(fp1,49L,SEEK_SET);
		for(int i=0;i<LEN;i++)
		{
			len_rec[i]=getc(fp1);
			//printf("%c \n",length[i]);
		}
		int length=atoi(len_rec);//获得行数
		char writefile1[18],writefile2[18],writefile3[18];
		//printf("%d \n",length);
		fseek(fp1,98L,SEEK_SET);//要跳过换行符!!
		fseek(fp2,98L,SEEK_SET);
		fseek(fp3,98L,SEEK_SET);
		for(int j=0;j<length;j++)
		{


			fgets(writefile1,14,fp1);
			fgets(writefile2,14,fp2);
			fgets(writefile3,14,fp3);
			//printf("%s",writefile1);
			fputs(writefile1,fpout);
			fseek(fp1,1L,SEEK_CUR);
			if (getc(fp1)=='-')
			{//printf("get it!!!!");
				fseek(fp1,-2L,SEEK_CUR);
				fgets(writefile1,16,fp1);
			}
			else
			{
				fseek(fp1,-2L,SEEK_CUR);
				fgets(writefile1,15,fp1);
			}
			fseek(fp2,1L,SEEK_CUR);
			if (getc(fp2)=='-')
			{//printf("get it!!!!");
				fseek(fp2,-2L,SEEK_CUR);
				fgets(writefile2,16,fp2);
			}
			else
			{
				fseek(fp2,-2L,SEEK_CUR);
				fgets(writefile2,15,fp2);
			}
			fseek(fp3,1L,SEEK_CUR);
			if (getc(fp3)=='-')
			{//printf("get it!!!!");
				fseek(fp3,-2L,SEEK_CUR);
				fgets(writefile3,16,fp3);
			}
			else
			{
				fseek(fp3,-2L,SEEK_CUR);
				fgets(writefile3,15,fp3);
			}


			//printf("%s",writefile1);
			//printf("%s%s",writefile1,writefile2);
			//printf("%s%s%s",writefile1,writefile2,writefile3);
			fputs(writefile1,fpout);//putc(' ',fpout);
			fputs(writefile2,fpout);//putc(' ',fpout);
			fputs(writefile3,fpout);
			
			fseek(fp1,2L,SEEK_CUR);
			fseek(fp2,2L,SEEK_CUR);
			fseek(fp3,2L,SEEK_CUR);
			//printf("\n");
			fputs("\n",fpout);
			

		}

		
		return 0;
} 

⌨️ 快捷键说明

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