how to plot the specific selection from listbox into axes1

Dear Users,
I am new to GUI of Matlab. In some part I found the success but in some I am stuck. It is difficult to come out with solutions as I am thinking.
I have 2 pushbutton and named them import and delete. 1 listbox1 and 1 axes1.
I wanted to import all the desired files and get them plotted into axes1. At the same time I will have the list of files displayed in listbox1. I got the success in doing it.
My problem is:
  1. I want to click on one particular file in listbox1 and get the display on axes1 plotted with red colour (overlap on earlier plot).
  2. I want to delete the selected file based on my observations.
3 I want to apply processing on remaining dataset.
Thank you for your help and suggestion.

5 commentaires

Unfortunatelly, I didn't see that you use GUI(haven't had the coffee yet). I wrote an answer for solving this with App Designer which might give you hints for your GUI.
Your problems need to be explained more carefully, each of those should be asked separately.
"1. I wanted to import all the desired files and get them plotted into axes1." If you go on your UIAxes1 in component browser, see the tab called Multiple Plots, option is Next Plot - Add. Every plot function call will be added on the UIAxes.
"2. I want to click on one particular file in listbox1 and get the display on axes1 plotted with red colour (overlap on earlier plot)." Does this earlier plot have already data from the file you want to plot? If yes, then can rather just change the color of observed data, if not then here's an idea.
Add a value changed callback on ListBox
% Value changed function: ListBox
function ListBoxValueChanged(app, event)
app.ListValue = app.ListBox.Value; % Set the value as a property
PlotSelection(app)
end
Helper function PlotSelection
If you save your files in array X whose rows correspond to each file, you can plot it this way
function PlotSelection(app)
plot(app.UIAxes, app.x(app.ListValue,:), app.y(app.ListValue,:), 'r');
end
"3. I want to apply processing on remaining dataset." I don't have a clue of what you want to do here.
Dear Maria,
Thank you for your reply.
"1. I wanted to import all the desired files and get them plotted into axes1." If you go on your UIAxes1 in component browser, see the tab called Multiple Plots, option is Next Plot - Add. Every plot function call will be added on the UIAxes.
Ans: I have plotted all the data.
"2. I want to click on one particular file in listbox1 and get the display on axes1 plotted with red colour (overlap on earlier plot)." Does this earlier plot have already data from the file you want to plot? If yes, then can rather just change the color of observed data, if not then here's an idea.
Ans: have a look on attached plot. suppose I click on 3 file from listbox. then it should be appear on on axes plot with red colour. it help me to observe the data visually.
3. I want to delete the selected file (i.e. 3rd no. from listbox) and keep the remaining four files for further processing.
I hope this time you got my quarry properly.
Thank you for your help.
I guess you didn't have your coffee either :)
You need two buttons, one for plotting and one for deleting . When the value from list is selected, clicking on a button will trigger a callback.
% Button pushed function: Button
function ButtonPushed(app, event)
PlotSelection(app)
end
For deleting a particular data from the plot, I can't tell exactly how to do it, you should search for other questions as it's a common question.
% Button pushed function: Button1
function Button1Pushed(app, event)
DeleteSelection(app)
end
:)))
Thank you Mario
my codes are attached. I am not using app designer.
Please take a look.
Thank you very much.
Mario Malic
Mario Malic le 8 Sep 2020
Modifié(e) : Mario Malic le 8 Sep 2020
Sorry, can't really help with GUI, since I have never used it.
That what I've written are just ideas how to solve your problem, it's possible to implement them in GUI, but I have never worked with it.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by