GUI store the output data in matrix

조회 수: 1 (최근 30일)
Jomei
Jomei 2020년 3월 13일
Hi,
Now I have 2 output data and 1 button. When I press the button in the firsr time, 2 output data will store in first row. And when I press second times, It will store in second row, and so on.
function Plotting_button_Callback(hObject, eventdata, handles)
%output data
d1=str2num(get(handles.d1,'string'));
assignin('base','d1',d1);
ns=str2num(get(handles.ns,'string'));
assignin('base','ns',ns);
% store data
Store_data = [];
i=1;
Data_Number = str2num(get(handles.Data_Number,'string')); % data number test box
Data_Number = Data_Number + 1; % add 1 if pressing the button
set(handles.Data_Number,'string' , Data_Number)
assignin('base','Data_Number_updated',Data_Number);
Store_data(Data_Number,1) = d1;
Store_data(Data_Number,2) = ns;
assignin('base','Store_data',Store_data); % store data
And now, it's able to become a matrix. but the matrix just has correct value when last press, other time the output values repalce number to 0.
For example, I press this button 9 times and I didn't change anything, so the number should be all 1. However it becomes
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
1 1
--------------

답변 (0개)

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by