how to write xls file

I have 3 plots in my graph.i have 3 checkboxes,each plot i have assigned it to check box.now i have created one pushbutton and i want to write xls file for checked button whenever pushbutton is pushed.it should look for checked button and should write xlsfile.can anyone help

 采纳的回答

Have each button callback call the same function "WriteWorkbooks(handles)". In that function, it checks each checkbox and writes the data if it's checked
function WriteWorkbooks(handles)
checkbox1State = get(handles.checkbox1, 'Value');
checkbox2State = get(handles.checkbox2, 'Value');
checkbox3State = get(handles.checkbox3, 'Value');
if checkbox1State
% Write whatever data you want to for this checkbox.
xlswrite(.......
end
if checkbox2State
% Write whatever data you want to for this checkbox.
end
if checkbox3State
% Write whatever data you want to for this checkbox.
end

5 个评论

thanks for solution.when i am saving file using xlswrite i want to display string name of checkbox also as header how to do that.and also for importing i used uigetfile and it will prompt for location of file similarly i want to save file in different location with different names how to do that,when i use xlswrite i will directly save in specified location,i want to save in different location in tht case how to do that
stringName = get(handles.checkbox1, 'String');
ca = {stringName};
xlswrite(filename, ca);
hi from your previous code i am able to write data into csv file but not able to write header.below is my code for this how to write can you please help.in first row i want all headers and from second row values
data=get(handles.uitable1,'data');
checkbox1State = get(handles.af1, 'Value');
checkbox2State = get(handles.af2, 'Value');
checkbox3State = get(handles.af3, 'Value');
if checkbox0State
header={'first'}
p=data(start_pt:end_pt,1);
xlswrite('af1.csv',p,1,'A2');
end
if checkbox1State
header={'second'}
p=data(start_pt:end_pt,2);
xlswrite('af1.csv',p,1,'B2')
end
if checkbox2State
header={'third'}
p=data(start_pt:end_pt,3);
xlswrite('af1.csv',p,1,'C2')
end
i was trying to write like
xlswrite('af1.csv',[header;p],1,'C2')
but am getting only string data and values are not getting written in csv file.
xlswrite doesn't write csv files - csvwrite() does that.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by