Can i call variable of another m file in GUI ?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello everyone,
i am designing a GUI for bellhop acoustic Toolbox, I m begineer in GUI designing. I wrote a program that can take few parameters as a input from user and run bellhop acoustic tool. I am wondering can i call variable of the another m file to GUI ? for example. If i want to take frequency as input parameter from user and put that user input frequency value to another m file and run bellhop when i press RunBellhop button ?
I am not sure how can i bind the variable of another m file to GUI ? Here I attach a screenshot of GUI and rough m file of GUI.
P.S. I am taking frequency input from user(GUI), writing that to another .m file and when i click on Run Bellhop button it should run below code
%=====================%
% Run Bellhop %
%=====================%
wbellhopenvfil('munkp',case_title,source_data,surface_data,ssp_data,bottom_data,options);
bellhop munkp
and plot the output in space provided :
%=====================%
% Reading output %
%=====================%
figure(2)
subplot(2,1,1)
counter = counter + 1 ; figure(counter)
plot( c , depths ), box on, grid on, view(0,-90)
xlabel('Sound speen (m/s)')
ylabel('Depth (m)')
title('Supply profile to bellhop')
subplot(2,1,2)
switch output_option
case '''C'''
plotshd( 'munkp.shd' ), box on, hold on
plot(rati, zati)
plot(rbty,zbty)
%plotssp( 'munkp' )
hold off
case '''E'''
plotray( 'munkp' ), box on, hold on
plot(rati, zati)
plot(rbty,zbty)
hold off
case '''R'''
plotray( 'munkp' ), box on, hold on
plot(rati, zati)
plot(rbty,zbty)
hold off
case '''IB'''
plotshd( 'munkp.shd' ), box on, hold on
plot(rati, zati)
plot(rbty,zbty)
%plotssp( 'munkp' )
hold off
otherwise
disp('Unknown output option.')
end
disp('done.')
Thanks in advance.
bellhopGUI.m
4 comentarios
Adam Danz
el 23 de Jul. de 2019
Nice work! Here are some recommendations
- use str2double instead of str2num https://www.mathworks.com/matlabcentral/answers/52243-why-str2double-is-preferred-over-str2num
- Unless 'test3.mat' is changed during the use of the GUI, just import that data once and use persistent variables (see block of code below).
% *not tested
persistent freq X %any other variable in the file that's needed
if isempty(freq)
data = load('test3.mat','freq','X');
freq = data.freq;
X = data.X;
end
Respuestas (0)
Ver también
Categorías
Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!