App Designer Edit Numeric how to express test

조회 수: 2 (최근 30일)
Lev Mihailov
Lev Mihailov 2020년 5월 12일
편집: Mehmed Saad 2020년 5월 12일
I need to create a graph in App Designer, but the graph is too large and I need to shorten it, I try to do this using Edit Numeric, but an error occurs Index exceeds the number of array elements (0)
function depthButtonMenuSelected(app, event)
title(app.UIAxes, 'Obj3010')
xlabel(app.UIAxes, 'zone')
ylabel(app.UIAxes, 'Ob')
app.Obj=app.Obj(app.a:app.b); % Index exceeds the number of array elements (0).
plot(app.UIAxes,app.d,'LineWidth',5);
end
%
function aEditFieldValueChanged(app, event)
app.a = app.aEditField.Value;
end
function bEditFieldValueChanged(app, event)
app.b = app.bEditField.Value;
end

답변 (1개)

Mehmed Saad
Mehmed Saad 2020년 5월 12일
편집: Mehmed Saad 2020년 5월 12일
it is because app.Obj is empty. it has no value.
First check what is app.Obj? maybe what you are trying to do is
app.d=app.d(app.a:app.b);
  댓글 수: 2
Lev Mihailov
Lev Mihailov 2020년 5월 12일
You were right, and I have one question, is it possible, when you click the button, the values ​​themselves were edited in Edit Numeric?
function MinAPushed(app, event)
app.a=1;
end
%
function MaxAPushed(app, event)
app.b=max(app.d);
end
Mehmed Saad
Mehmed Saad 2020년 5월 12일
편집: Mehmed Saad 2020년 5월 12일
see the attached app button callback
app.EditField_name.Value = app.a;
Also it is not necessary that max(app.d) is less than app.d length or is interger
For example
app.d = [1 2 6 4];
Now
app.b=max(app.d); % app.b is max value of app.d and not max value index
so app.b is 6 and now your code
app.d(app.a:app.b)
wil try to access app.d from 1st index to 6th index which doesnot exist
to get max value index see help of max

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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!

Translated by