필터 지우기
필터 지우기

How can I load a data vector from a .mat file to workspace and plot it (Using GUI)?

조회 수: 11 (최근 30일)
Annie
Annie 2015년 8월 24일
댓글: Annie 2015년 8월 24일
Hello, I'm working on a part of a GUI where I have to load a .mat file that contains some data vectors from the one the user will write one of the data vector's name in order to use it and plot it, I thought first on only leave the instructions with a edit text function but I then thought on using a push button to do everything, I'm thinking on make a variable that will save the name of the needed data vector and with that variable find the vector from the .mat file and plot it, but I'm having problems with everything. This is some of what I have tried:
load('datosnoembarazo.mat') %this is the .mat file I'll work with
global ingesta
ingesta=char(get(handles.edit3,'String')); %I'm putting in the variable "ingesta" the vector's name as character
assignin('base','ingesta',ingesta); %Saving the variable
axes(handles.axes4);
plot(ingesta)
grid on;
I know that the error I have there is that I'm sending the characters to be plotted, but how can I make that the typed characters get recognized as the vector's name? Also I think that this code is not loading the .mat file, because I don't see it in the workspace, can you please help me with this? I'm really new into GUI programming, thanks!
  댓글 수: 1
Annie
Annie 2015년 8월 24일
I've been working on this, I could load the file 'datosnoembarazo.mat' as an structure to the Workspace with:
global newData1;
newData1=importdata(get(handles.edit1,'String'))
assignin('base','newData1',newData1)
but I need to get the vectors that it has to plot them, for example:
plot(newData1.glucosa1)
I could do this in the Command Window but still can't in the GUI programming, can someone help me please? Thanks

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by