How to smooth multiple datasets in app Designer with one slider
Mostra commenti meno recenti
Hello everyone, please I need help with smoothing imported data in App Designer interactively.
I have 4 datasets and 4 seperate buttons to plot them one dataset per time on one axis.
data1
data2
data3
data4
Now I want to make a custom slider that smoothens each plotted data showing on the axes but I'm not quite sure how to do that.
smootheddata1=smooth(app.data1,changingValue)
hold(app.UIAxes, 'on')
plot(app.UIAxes, data1, smootheddata)
hold(app.UIAxes, 'off ')
I saw that this code above is used to smooth a particular data series but how do I do that for every plotted dataset using one slider. I want the slider to perform smoothing for any plotted data using the data1, data2, data3 or data4 buttons
Thanks in advance
Risposte (1)
TADA
il 28 Lug 2021
0 voti
If I understand correctly this time, you have 4 datasets, you want to plot one of them and you want to control the smoothing with the slider. correct?
save all your datasets in a list (cell array if the sizes are prone to change which is quite likely, or they are tables or whatever), and keep a separate property which tells you the index of current plotted dataset.
Then when you choose to plot this dataset or the other you update the currentPlottedDataSetIndex property and plot.
The slider should have a callback function which also plots argain.
when plotting you take the desired dataset from the list (using the index saved in the currentPlottedDataSetIndex property), apply smoothing then plot it.
The example I posted last time still holds but the datasets should be handled as a list.
5 Commenti
Daniel Abraham
il 3 Ago 2021
TADA
il 8 Ago 2021
It is all fairly simple
I updated the example from last time, I made it a crude example without using any fancy good coding practices. still it should help you solve your problem
This example generates the data in the button callback functions. The data is generated as a matrix with two columns, the first one being X axis values and the second Y axis values, and adds some random noise for you to smooth.
You can obviously change the workings of the button callback functions to load data from file or whatever it is you are trying to do.
Naturally, you will need to update the function extracting X and Y values from the current dataset as well.
Daniel Abraham
il 8 Ago 2021
TADA
il 8 Ago 2021
Daniel, I can run it on my system.
I think gaussmf is part of the fuzzy logic toolbox, but you can just replace it with any other calculation for the sake of this example:
x = linspace(0, 3.5);
y = 2*exp(x) + 10*rand(1, length(x)) - 5;
Categorie
Scopri di più su Graphics Performance in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!