problem from reading data from a .txt file
2 次查看(过去 30 天)
显示 更早的评论
Hello I have 20000 data located in a .txt file.this data genarated by randi function of matlab..
my notepad is looks like this
Columns 1 through 20
160 7 121 126 83 106 41 6 183 132 68 105 42 62 194 214 122 73 194 187
Columns 21 through 40
16 253 10 199 249 106 79 154 34 46 116 83 122 11 6 .......more
now I need to read data from this .txt.. my code is
fid = fopen('D:\data_1.txt');
A = fscanf(fid, '%g', [2 inf]);
fclose(fid);
X=reshape(A,20000,1);
but I am getting error on RESHAPE function...it says "To RESHAPE the number of elements must not change."
in workspace A is blank..whats going wrong?
0 个评论
回答(1 个)
Jing
2012-10-31
Hi,
Can you try to use the default setting of FSCANF function?
Like A=fscanf(fid,'%g');
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!