Saving data points as a row and column
古いコメントを表示
I have a program that takes points from a file and give the answer for each input point. Keep in mind that is being done in a loop. I want to take those results points and store them in a file. But when I use Fid=fopen(file, w+), it keeps updating the points so not all of them saved in there. On top of that I have another str2double points that I wan to save to the same file in a different column. That would give me two column of data points for me to plot. Can anybody hel? Because of the for loop it's keep writing and updating. When I use 'a' or 'a+' it appends but does not update. I want it to write all the points each in different row like this: First Sec
1. 3
2. 4
3. 5
But because of the loop it only keep the last points in the file
For k=1:1:21
Txt=importdata(file.txt, %s)
T=sscanf(Txt{k})
Y=str2double(T)
Fid=fopen(file,w)
fprintf(fid, %s, Y)
But it just won't keep all 21 values of y
1 件のコメント
Azzi Abdelmalek
2013 年 3 月 4 日
Post your loop
回答 (1 件)
Mini Me
2013 年 3 月 5 日
0 投票
3 件のコメント
There is no Fprintf() command in Matlab, because the upper/lowercase matters. The format string of '%s' and the file name require quotes. sscanf() works sufficiently with a format string also. There is no need to import the file repeatedly inside the loop. The doubles in Y cannot be stored in the file by fprintf('%s'), bit you need a numerical format specifier.
On first sight there are 11 serious errors in your code. This is not useful for answering your question. Please debug the code at first and post a well formatted copy in the original question, not as an answer. Thanks.
Mini Me
2013 年 3 月 5 日
Walter Roberson
2013 年 3 月 5 日
Are you hoping for a sloppy answer or a correct one?
カテゴリ
ヘルプ センター および File Exchange で Historical Contests についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!