I need h help i save value in xlsx format through push button function
1 次查看(过去 30 天)
显示 更早的评论
Hi Dear Sir,
I need h help i save value in xlsx format through push button function. I hope a better code solution forwrd me thanks.
These data value want to save with new function of push button. My code is below:
data = get(handles.uitable1, 'Data');
data{1, 1} = num2str(Contrast(1));
data{1, 2} = num2str(Contrast(2));
data{1, 3} = num2str(Contrast(3));
data{1, 4} = num2str(Contrast(4));
data{1, 5} = num2str(mean(Contrast));
data{2, 1} = num2str(Correlation(1));
data{2, 2} = num2str(Correlation(2));
data{2, 3} = num2str(Correlation(3));
data{2, 4} = num2str(Correlation(4));
data{2, 5} = num2str(mean(Correlation));
data{3, 1} = num2str(Energy(1));
data{3, 2} = num2str(Energy(2));
data{3, 3} = num2str(Energy(3));
data{3, 4} = num2str(Energy(4));
data{3, 5} = num2str(mean(Energy));
data{4, 1} = num2str(Homogeneity(1));
data{4, 2} = num2str(Homogeneity(2));
data{4, 3} = num2str(Homogeneity(3));
data{4, 4} = num2str(Homogeneity(4));
data{4, 5} = num2str(mean(Homogeneity));
global AA1 AA2 AA3 AA4 AA5 AA6 AA7 AA8 meann
AA1 = Mean;
AA2 = Standard_Deviation;
AA3 = Entropy;
AA4 = Variance;
AA5 = Smoothness;
AA6 = Kurtosis;
AA7 = Skewness;
AA8 = IDM;
set(handles.edit3, 'string', AA1);
set(handles.edit5, 'string', AA2);
%set(handles.edit7, 'string', RMS);
set(handles.edit9, 'string', AA3);
set(handles.edit11, 'string', AA4);
set(handles.edit13, 'string', AA5);
set(handles.edit15, 'string', AA6);
set(handles.edit17, 'string', AA7);
set(handles.edit19, 'string', AA8);
handles.saved = data;
set(handles.uitable1, 'Data', data)
guidata(hObject, handles);
4 个评论
Jan
2022-7-13
@Tanveer Aslam: Please answer Rik's questions for clarifications. This would allow to understand your code and to post amatching solution.
采纳的回答
Rik
2022-7-13
Because you used global variables instead of sharing data through the guidata struct, it is impossible to know what went wrong. You also used an extremely short name, which increases the chance of a collision with some other function that might be poorly designed and made the same mistake.
For general advice and examples for how to create a GUI (and avoid using GUIDE), have look at this thread. That will also show you how to share data between callbacks.
There is nothing fundamentally wrong with your xlswrite call. The problem is with the data sharing. You're also using numbered variables, which tend to be a sign you're not using arrays effectively.
However, for your specific example it is actually quite simple: your first callback does not assign any value to the global q variable, so the second callback will try to write whatever the last function that happened to use q as a global assigned to it.
2 个评论
Rik
2022-7-13
Glad to be of help.
I don't do private consulting. This forum is a hobby for me. If you want private help, there are many people who would be happy to help you for a fee.
If you want my help, it will be on this forum in public, and without any guarantees. Feel free to tag me in a new post or post the link in a comment here.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!