error "Index exceeds matrix dimensions." in my GUI

1 vue (au cours des 30 derniers jours)
Soni huu
Soni huu le 28 Jan 2013
i can't fix this error
Index exceeds matrix dimensions.
Error in bulanan (line 11)
bar( mr(inthn).Rain );
Error in rancang1>pushbutton1_Callback (line 129)
bulanan
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in rancang1 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
@(hObject,eventdata)rancang1('pushbutton1_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
my code
pushbutton callback
RainData=handles.data
jeda = get(handles.listjeda,'value');
switch jeda
case 1
bulanan
case 2
harian
end
bulanan.m
inthn = get(handles.pilihtahun,'value');
switch inthn
case 1
1;
case 2
2;
end
mr = MonthlyRain( RainData );
bar( mr(inthn).Rain );
ylabel('Akumulasi Curah Hujan (mm)')
xlabel('Bulan')
  3 commentaires
Walter Roberson
Walter Roberson le 28 Jan 2013
We need to know more about MonthlyRain and RainData. If MonthlyRain(RainData) is producing a scalar, you would get the problem.
Soni huu
Soni huu le 28 Jan 2013
Modifié(e) : Soni huu le 28 Jan 2013
if i change bulanan file with ;
mr = MonthlyRain( RainData );
bar( mr(1).Rain );
ylabel('Akumulasi Curah Hujan (mm)')
xlabel('Bulan')
=== no error but pushbutton process wrong data, the pushbutton result is bar mr(2) (not bar mr(1))
or, if i change with;
mr = MonthlyRain( RainData );
bar( mr(2).Rain );
ylabel('Akumulasi Curah Hujan (mm)')
xlabel('Bulan')
=== error with msg ;
Index exceeds matrix dimensions.
Error in bulanan (line 11)
bar( mr(inthn).Rain );

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Jan 2013
I have not checked your data file, but it appears your data file only has information for a single year. Your rain_data structure will only have as many array members as there are distinct years in your data.
  2 commentaires
Soni huu
Soni huu le 29 Jan 2013
i have 2 year data.. in a folder:
bar( mr(1).Rain ); %2010 data
bar( mr(2).Rain ); %2011 data
Soni huu
Soni huu le 29 Jan 2013
thanks, in my folder just single year, that wrong folder..
:(

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by