Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Problem Holding imported data in my GUI environment
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi. I am writing a GUI program that will import data from excel then later process and plot the k-means cluster after after clicking on a button. A button is also clicked for uploading the data into the GUI. The problem am having is that after successfully uploading and am unable to hold the data in the GUI, and i also want to display a message that will show that the data has been uploaded and another that the cluster was successful. pls this is the part holding my work down. the code i used is below. Thanks in advance. The first part below is how i uploaded the data.
global X
[filename, pathname] = uigetfile('.xls','Select the file');
[X] = xlsread(filename, 2);
msgbox('Data Successfully Uploaded')
This is the first part of my cluster.
X1=5*[X(40,1).*rand(40,1), X(40,1).*randn(40,1)];
X2=5*[X(40,2).*rand(40,1), X(40,2).*randn(40,1)];
X3=5*[X(40,3).*rand(40,1), X(40,3).*randn(40,1)];
X4=[X(40,4).*rand(40,1), X(40,4).*rand(40,1)];
X5=5*[X(40,5).*randn(40,1), X(40,5).*randn(40,1)];
X6=5*[X(40,6).*randn(40,1), X(40,6).*randn(40,1)];
X7=[X(40,7).*rand(40,1), X(40,7).*randn(40,1)];
X8=5*[X(40,8).*randn(40,1), X(40,8).*rand(40,1)];
X9=5*[X(40,9).*rand(40,1), X(40,9).*rand(40,1)];
X10=[X(40,10).*randn(40,1), X(40,10).*randn(40,1)];
X11=[X(40,11).*randn(40,1), X(40,11).*randn(40,1)];
X12=5*[X(40,12).*rand(40,1), X(40,12).*randn(40,1)];
plot(X1(:,1),X1(:,2),'.'); hold on
plot(X2(:,1),X2(:,2),'y.');
plot(X3(:,1),X3(:,2),'m.');
plot(X4(:,1),X4(:,2),'c.');
plot(X5(:,1),X5(:,2),'r.');
plot(X6(:,1),X6(:,2),'g.');
plot(X7(:,1),X7(:,2),'b<');
plot(X8(:,1),X8(:,2),'yo');
plot(X9(:,1),X9(:,2),'m+');
plot(X10(:,1),X10(:,2),'c*');
plot(X11(:,1),X11(:,2),'rs');
plot(X12(:,1),X12(:,2),'gv');
grid on
% Accumulate all data
all_data = [X1;X2;X3;X4;X5;X6;X7;X8;X9;X10;X11;X12];
IDX = kmeans(all_data,12);
for k=1:481
text(all_data(k,1,all_data(k,2),num2str(IDX(k))));
hold on
end
axis([-70 70 -70 70])
Y = pdist(all_data);
Z = linkage(Y);
T = cluster(Z, 'cutoff', threshold);
close all
for k = 1:40
text(all_data(k,1,all_data(k,2),num2str(IDX(k))));
hold on
end
axis([-70 70 -70 70])
Thanks in advance...
1 Commento
Oleg Komarov
il 16 Ago 2012
Please format the code with markup as explained here: http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Risposte (1)
Ryan G
il 16 Ago 2012
The issue appears to be you are not storing your data in the GUI only locally in the function.
You could try something like this at the end:
handles.all_data = all_data;
guidata(hObject, handles);
This will store the data in the handles structure and assign it to the GUI so that it will be passed between the functions with hObject inside the GUI.
From here you will probably be able to figure out the rest.
0 Commenti
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!