필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Problem Holding imported data in my GUI environment

조회 수: 2 (최근 30일)
Muhammad Mubarak
Muhammad Mubarak 2012년 8월 16일
마감: MATLAB Answer Bot 2021년 8월 20일
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개)

Ryan G
Ryan G 2012년 8월 16일
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.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by