Info
La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.
Matlab OOP and Warndlg Crashing Matlab
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I have recently started using OOP in Matlab. I have defined a class "ReadFile" that accepts a file name via a constructor class. The class has a dependent variable "file". The get method for the variable "file" is defined by calling an external function. The external function has some error check logic which uses "warndlg" to display error.
Here is the class:
classdef ReadFile
properties
% some vars
fileName;
end
properties(dependent=true)
file;
end
methods
% constructor class
function obj=ReadFile(fileName)
obj.fileName = fileName;
end
% get method for dependent
function fileInfo=get.file(obj)
fileInfo = ExternalFunc(obj.fileName);
end
end
The ExternalFunc is a file read function that displays an warning dialogue if the file cannot be opened and it outputs an empty variable in place of fileInfo.
The main script looks like this:
read = ReadFile('myFile.txt');
data = read.file
This creates two variables in the workspace: "read" class and "data". If I input the incorrect file name then the class as expected displays the warndlg but if I try to open the "read" class from the workspace it again reopens the warndlg and keeps on opening it over and over. I can't stop execution hence I have to terminate the Matlab session. I am trying to investigate the root cause. I suspect given that I am new to OOP in Matlab, I am missing something basic.
I would appreciate any suggestions.
Thanks! Abhay
2 comentarios
Geoff Hayes
el 5 de Abr. de 2015
Abhay - please clarify what you mean by try to open the "read" class from the workspace it again. What are you trying to open - the read instance or the file that read references?
Respuestas (0)
La pregunta está cerrada.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!