Matlab GUI

1 次查看(过去 30 天)
Simone Leon
Simone Leon 2011-10-23
I am creating a matlab gui and I have two problems I would like to solve: Problem 1 I would like to use a push button to load some data from a matlab file loacted on the C drive to the workspace. The variable name is 'MyData' and the location of the file is C:\Simulation\LoadFile.
Problem 2 While a simulation is running in matlab, I would like to view the contents of the command window in an edittext box in the Matlab GUI simultaneously. Is this possible? Presently I have to switch to the command view to see when the simulation is complete. I just want to stay on the GUI and view the contents.
Thank you for any assistance you can give

采纳的回答

Image Analyst
Image Analyst 2011-10-23
1. In the callback construct the filename, check to see if it exists, then read it in.
% Get the full filename, with path prepended. fullFileName = fullfile('C:\Simulation\LoadFile', MyData);
if ~exist(fullFileName, 'file')
% Didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
% Now, read in the file in whatever way you do it.
Problem 2: Why not just use sprintf() to construct some string, then use set() to set the 'String' property of a static text to be that string? Why mess with the command window at all???

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Text Data Preparation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by