How to store continuous data from Matlab GUI.

조회 수: 3 (최근 30일)
gdz
gdz 2023년 6월 12일
답변: Divyajyoti Nayak 2025년 6월 2일
Hi,
I have built a matlab gui that read the data obtaining from Simulink. The matlab gui do some calculation and store it in some variables. Now, I would like to store the data of those variables from matlab gui.
I have tried to use assignin, but this function only save the last data(a scalar), but not data changing with time.
Please let me know are there any function that allow me to store the data according to time.
Thank you.

답변 (1개)

Divyajyoti Nayak
Divyajyoti Nayak 2025년 6월 2일
Hi @gdz,
To store data each time the GUI makes the calculations, rather than assigning the result to a variable the result should be appended like this:
result = [1, 2, 3, 4];
newResult = [5];
result = [result, newResult]
result = 1×5
1 2 3 4 5
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Here's some sample code showing the difference:
result1 = [];
result2 = [];
for i = 1:10
%Do calculations
newResult = i; %new result after calculation
result1 = newResult; %Only stores latest result
result2 = [result2, newResult]; %Stores all previous results as well
end
result1
result1 = 10
result2 %This can be then extracted from GUI
result2 = 1×10
1 2 3 4 5 6 7 8 9 10
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by