Saving data using uiputfile

조회 수: 6 (최근 30일)
James Hendren
James Hendren 2013년 8월 1일
I need to create a .dat file. I have a graph and I want to save the values of the x and y axes into a .dat file with a column representing each of the axes. So how would I retrieve the data from the graph and save the date in the manner specified? i have two pieces of code attached
get(handles.axes3) <---should this be get(handles.axes3,'Data') ?
get(handles.axes4)
global frequency calculatedEps1 calculatedEps2
[fileName, filePath] = uiputfile('*.dat', 'Create a file:');
if ~ischar(fileName);
return;
end;
fileID = fopen(fullfile(filePath, fileName), 'w');
fileID = fopen(name);
BBB = fprintf(fileID, '%c');
B = num2str(BBB);
frequency = B(:,1);
calculatedEps1 =B(:,2);
calculatedEps2 =B(:,3);
or
[name,path] = uiputfile('*.dat');
namev = fullfile(path,name);
fid = fopen(namev,'w');
  댓글 수: 2
Walter Roberson
Walter Roberson 2013년 8월 1일
You have
BBB = fprintf(fileID, '%c');
the result of the fprintf() is going to be the number of bytes output. But what bytes are you trying to output '%c' is a format specifier, and you have not passed any data to be formatted with '%c' ?
James Hendren
James Hendren 2013년 8월 1일
well I was trying to recreate some code I had previously seen. I would really just like some code to do what I stated in the problem.

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

답변 (1개)

James Hendren
James Hendren 2013년 8월 1일
[name,path] = uiputfile('*.dat');
namev = fullfile(path,name);
fid = fopen(namev,'w');
fprintf(fid,'%f\t',num2str(get(handles.axes3,'Data')));
would this be better for what I want?

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by