Error with parsing data from one window to another in app designer
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello All,
Ik keep having the error "Unable to use a value of type Analyzer as an index.". Even though Analyzer is not a Variable or Function it is the name of my MainApp. I would like to snd data from one window to another and thought I had done all correct and now I get this error but I don't kno wwhere to look anymore cause I dont understand this has something to do with indexing. So Ill show my code below and maybe someone could point me out what I do wrong.
First some properties which I have in the MainApp called "Analyzer
properties (Access = private)
frmPreferences;
X1; %X1 = raw selected data from Load data class
X2;
Y1; %Y1 = raw selected data from Load data class
Y2; %Y2 = raw selected data from Load data class
YBprocessed;
YRprocessed;
Xprocessed;
StartSample;
EndSample;
SampleFrequency;
FileName;
CallData;
end
Then When I would press on the menubar the option "Preferences" I want another window opens. In this case it sends from the main window to the Preference Window a number (SampleFrequency). This is for testing purposes
function PreferencesMenuSelected(app, event)
t = num2str(app.SampleFrequency);
app.frmPreferences = app.frmPreferences(app, t);
end
Next the code in the second window called "frmPreferences" with its properties
properties (Access = private)
Callingapp;
end
And the code when the window get opened:
function startupFcn(app, Analyzer, DatafrmAnalyzer)
app.Callingapp = Analyzer;
app.lblSampleFreq.Text = DatafrmAnalyzer;
end
I have also tried to rename Analyzer but this dont make any differences. So I hope someone can help me a bit.
Thanks in advance
댓글 수: 0
채택된 답변
Kevin Holly
2022년 2월 23일
I like to keep things simple and just read from main app.
Main app (Analyzer):
properties (Access = private)
frmPreferences;
X1; %X1 = raw selected data from Load data class
X2;
Y1; %Y1 = raw selected data from Load data class
Y2; %Y2 = raw selected data from Load data class
YBprocessed;
YRprocessed;
Xprocessed;
StartSample;
EndSample;
SampleFrequency;
FileName;
CallData;
end
function PreferencesMenuSelected(app, event)
app.frmPreferences = frmPreferences(app);
end
frmPreferences:
properties (Access = private)
Callingapp;
end
function startupFcn(app, Analyzer)
app.Callingapp = Analyzer;
app.lblSampleFreq.Text = num2str(app.Callingapp.SampleFrequency);
end
OR
If you need to use t again, you could save it as a property of the main app.
Main app (Analyzer):
properties (Access = private)
frmPreferences;
X1; %X1 = raw selected data from Load data class
X2;
Y1; %Y1 = raw selected data from Load data class
Y2; %Y2 = raw selected data from Load data class
YBprocessed;
YRprocessed;
Xprocessed;
StartSample;
EndSample;
SampleFrequency;
FileName;
CallData;
t
end
function PreferencesMenuSelected(app, event)
app.t = num2str(app.SampleFrequency);
app.frmPreferences = frmPreferences(app);
end
frmPreferences:
properties (Access = private)
Callingapp;
end
function startupFcn(app, Analyzer)
app.Callingapp = Analyzer;
app.lblSampleFreq.Text = app.Callingapp.t;
end
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!