change only 3 of many outputs of a function through the App Designer

1 view (last 30 days)
I have an Configuration.m file with many variables. I use it as a configuration settings file.
It contains many variables, which I change every time in order to get different plots. After I change them I run the file through another function which uses the variables of the Configuration.m file.
I am trying to create an App via App Designer for the program I have made.
On the app designer I would like to control and change the variables of the Configuration.m file, that's why I converted the Configuration.m file to a function file.
From all the outputs of the Configuration function(now) I would like to change specific outputs.
How am I supposed to access and modify through the app designer only the outputs that interest me ?
  2 Comments
Mario Malic
Mario Malic on 5 Nov 2020
What does it mean many variables? what type of variables are there? How does your program read them? Are you running the script and getting the variables from workspace?
Write a short example of your code please, and we can suggest something.
Michail Kanoupakis
Michail Kanoupakis on 6 Nov 2020
Edited: Rik on 6 Nov 2020
This is the start of the Configuration.m file and some of its elements
%% Variables for the Neuronal Analysis file
fs = 6000; % Acquisition frequency
NChannels = 1024; % Number of channels
ichan = str2double('4'); % Channel for testing plots
InvertData = str2double('0'); % Invert the data
%% Preprocess of the data
FileType = 'hdf5';
FilterData = 1; %filter the raw data
ExtractSpikes = 0; %extract spikes
SaveData = 0; %if you want to save the preprocessed data in .mat file
Precision = 'mV'; %V, mV, \muV (to plot ?V in matlab in the correct form)
% Filter data
fmin = 300; %high pass filtering frequency
fmax = 2750; %low pass filtering frequency, why when >=3000...error
FilterType = 'ellip'; %type of the filter butter or elliptic
after I edit my configuration settings I run this file/function
function NeuronsAnalysis()
%% Code for the analysis of neuronal data
% clear all
close all
clc
%% Add all folders to path:
setup()
%% MATLAB Init
%set all variables in the configuration file
Configuration
%% Import new data
% Load file
[fileName,path] = uigetfile({'*.sparrowh5';'*.txt';'*.bin';'*.mat';'*.*'},'Please specify the import file');
[Full_Path, fileName, Data] = LoadFile(FileType, NChannels, fileName, path);
I would like for example to edit through the app designer (I am using the component Edit Field Numeric) the fmin and the fmax variables of the configuration file and then run the NeuronsAnalysis()

Sign in to comment.

Accepted Answer

Mario Malic
Mario Malic on 6 Nov 2020
Edited: Mario Malic on 7 Nov 2020
I am not sure what would be the easiest way considering that Configuration.m generates a file. After you call Configuration, you can read file, edit and save it again, or you can do it after you call LoadFile.
You can create a helper function or write code directly after LoadFIle that will set variables values according to the value in component Edit Field Numeric.
Data.fmin = app.EditFieldComponent1.Value;
Data.fmax = app.EditFieldComponent2.Value;
Edit:
This would work if your function NeuronsAnalysis() would receive app as input argument and if you'd call the function within the app.

More Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!