Saving data points as a row and column

조회 수: 2 (최근 30일)
Mini Me
Mini Me 2013년 3월 4일
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개)

Mini Me
Mini Me 2013년 3월 5일
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
  댓글 수: 3
Mini Me
Mini Me 2013년 3월 5일
That I know I was just being sloppy. Just a vague idea how the program is
Walter Roberson
Walter Roberson 2013년 3월 5일
Are you hoping for a sloppy answer or a correct one?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by