GUI push button help

3 visualizzazioni (ultimi 30 giorni)
Jo Smi
Jo Smi il 5 Feb 2022
Commentato: Jo Smi il 5 Feb 2022
I am so sorry to be asking this. I am new to the whole gui enviornment and I feel a bit lost with it.
I am trying to create a push button, which lets me upload data and then graph the data. The file I want to upload has 3 columns: date / time / activity. I want to be able to upload this data with the push button and to graph time and activity.
So far I have made this
[dataFile, dataPath] = uigetfile('*.*');
data=[dataPath dataFile];
[fid, msg] = fopen(dataFile, 'r');
and it only lets me select my file but it doesn't seem to upload it. Am I missing something trivial? I am so sorry if this is a stupid question I am learning matlab now...
thank you!

Risposte (1)

Cris LaPierre
Cris LaPierre il 5 Feb 2022
Modificato: Cris LaPierre il 5 Feb 2022
What error message are you getting?
You probably need to use fullfile to properly construct the path+filename, and then use that to load your file. See the examples on the uigetfile documentation page.
Also, fopen does not load a file. It opens it so you can then read it in. I suggest using readtable. This will load the data into a table, so see the Access Data in a Table page for how to work with this data type.
[dataFile, dataPath] = uigetfile('*.*');
data=fullfile(dataPath,dataFile);
[fid, msg] = readtable(data);
You might also find it helpful to go through the app designer tutorial. Following that, there are several examples you can load and look at and learn from.
  3 Commenti
Cris LaPierre
Cris LaPierre il 5 Feb 2022
No, guis operate in their own workspace. You will not see the results in the MATLAB workspace. Think of it as writing functions. You can still inspect your code as you are used to doing, but you will need to learn to use the debugging tools in order to do so.
Jo Smi
Jo Smi il 5 Feb 2022
Thank you so much!

Accedi per commentare.

Categorie

Scopri di più su Workspace Variables and MAT Files in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by