Matlab中:
save(['patterns\' num2str(i) 'P.txt'], 'pattern1', '-ASCII');
VS中:
#include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
string convertInt(int number)
{
stringstream ss;//create a stringstream
ss << number;//add number to the stream
return ss.str();//return a string with the contents of the stream
}
例子1:
ifstream fin_path("Config4.txt");
int time_folder[6];
fin_path>>time_folder[0];
fin_path>>time_folder[1];
fin_path>>time_folder[2];
fin_path>>time_folder[3];
fin_path>>time_folder[4];
fin_path>>time_folder[5];
fin_path.close();
例子2:
string path = "C:\\Users\\cmoslab\\Documents\\Jian's research\\Project-SinglePxlCam-Hadamard\\DMD_Control\\patterns\\";
ifstream fin((path+convertInt(9)+"N.txt").c_str());
for (int i = 0; i < 768; i++)
{
for (int j = 0; j < 1024; j++)
{
fin>>pattern[i][j];
}
}
fin.close();