How to create multiple variables/structs in GUIDE

I want to display data from several csv-files in some plots. To distinguish the data, I want to chose a number from 1-10 via a Pop-Up-menu before I press a button, which starts the textscan. Is it possible to create a variable in guide named 1,2,3-10 (dependend from the Pop-Up-Menu), in which the data of several columns of data from the csv-file is stored? I use „case“ for storing the number by setappdata(handles.number, ‚Number‘, 1-10) in the pop-up-menu. I don´t know how to create variables, that can be used by further callback functions like 1.column1, 1.column2 (from the first csv-file and number one chosen by the pop-up-menu), 2.column1, 2.column2 (second csv-file and number two chosen from the pop-up-menu), and so on. I would be happy, if someone could help me with this problem….

 采纳的回答

Just get the selected item from a popup that you placed on the GUI in GUIDE. So in the callback function for that popup (let's say it's called popColumn), do
selectedColumn = handles.popColumn.Value;
You can do that from ANY callback function or any other function that has access to handles.
Now just use that to do whatever you want. So if you have matrices m1, m2, m3, etc. and you wanted that column from m2, you'd just do
columnValues = m2(:, selectedColumn); % Extract specified column from m1.

2 个评论

Thanks for this quick response and effort. Unfortunately this is not the application I was looking for. I want to read in csv-Files and save their data. Dependent on which number was choosen in the pop-up-menu, the created variables should have a name, that includes the number. Till now I don´t really understand how to save variables by using gui. Can I create my own variables like handles.(Numberfrom pop-up-menu)? And if so, how can this be done. Subsequent I want to save all the created variables 1-10 with all the information, in order to work with this data afterwards. How can this be done? I also want to acces these data via guitable, which is not possible till now...
You can get the index of the popup and then assign/create whatever variable you want:
selectedIndex = handles.popup1.Value;
switch selectedIndex
case 1
var1 = csvread(filename);
case 2
var2 = csvread(filename);
case 3
var3 = csvread(filename);
etc.

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Simulink 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by