Hello, I've an application that changes the color of a pushbutton but I have 25 pushbuttons and I don't want to copy/paste the code, how can I create a function that recieves the button as a parameter and change the color? here's the code:
% --- Executes on button press in cell11.
function cell11_Callback(hObject, eventdata, handles)color=get(handles.cell11,'BackgroundColor');if(color==[0.94,0.94,0.94]) set(handles.cell11,'BackgroundColor',[0,0,0]);elseif(color==[0,0,0]) set(handles.cell11,'BackgroundColor',[0.94,0.94,0.94]);end% hObject handle to cell11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Best Answer