Azzera filtri
Azzera filtri

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

11 visualizzazioni (ultimi 30 giorni)
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 Commento
Annie
Annie il 24 Ago 2015
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

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Get Started with MATLAB in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by