help in using simulink
Hi,
I am stucked with my FYP and wondering is there any geeks in Matlab who can help me with it? My project involves using fuzzy logic toolbox. I am stucked in linking the toolbox onto simulink and output onto a GUI.
Seems simple but I know nuts abt Matlab hence really need some help here.
Anyone??
I am stucked with my FYP and wondering is there any geeks in Matlab who can help me with it? My project involves using fuzzy logic toolbox. I am stucked in linking the toolbox onto simulink and output onto a GUI.
Seems simple but I know nuts abt Matlab hence really need some help here.
Anyone??
0
Comments
thanks for the info. I've seeked help in Kluid too. Hopefully someone reply.
Hi,
glad to hear that. I need help in both cos I'm just too weak in that. Are u familiar with fuzzy logic toolbox? I have created a GUI with 2 edit text box for input, a push button to process the inputs and with the fuzzy logic toolbox, to generate an output value. However I just dont know how to program the toolbox into the GUI. I've attached pictures of the GUI.(see 2nd picture). Will you be able to enlighten me on this??
Hey really thankful for your prompt response. Sorry I did not explain clearly. So far I only managed to program the input space such that there is an error message appearing if a non numerical value is entered. Besides that I do not know how to continue. I do have problem making the buttom press call functions from the toolbox with input values. I'm not sure how to call out the output onto the GUI too. Sorry to trouble you on this....but it will be wonderful if you can shed some light for me on this. If you dont mind we can chat on msn and will explain clearer...if its more convenient for u.
You need to set the callback for the button:
When you create the button, you will be able to get it's handle (h). now all you need to do is write the function my_button_callback(arg1, arg2) with however many arguments you need. These arguments should probably be whatever is in your text boxes. You can have as many arguments as you need/like. Inside that function you can use those arguments as you desire. One of the arguments could also be a handle to the 'result' textbox, and you could use that handle to set the text.
Hi I'm sorry but I am poor in understanding programming lingo. Pardon my ignorance. Here are the programs for my edit boxes so far. I've yet to enter any programs for push button and edit4. Could you enlighten me further pls?
I'm really sorry to trouble you. If you need to get busy with other stuff pls go ahead.
function edit2_Callback(hObject, eventdata, handles)
user_entry = str2double(get(hObject,'string'));
if isnan(user_entry)
errordlg('You must enter a numeric value','Bad Input','modal')
return
end
function edit3_Callback(hObject, eventdata, handles)
user_entry = str2double(get(hObject,'string'));
if isnan(user_entry)
errordlg('You must enter a numeric value','Bad Input','modal')
return
end
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
function edit4_Callback(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
% str2double(get(hObject,'String')) returns contents of edit4 as a double
so the 3rd argument to all those functions is the list of handles. think of a handle as a pointer to the assorted objects (edit boxes, buttons, etc). From that handle, you can get/set information.
what that means is that you can access any information you want about any of the other objects.
As a test, why not try making the pushbutton just set the text of the last textbox to the sum of what's in the first and second textbox.
So, now you know how to get the strings from the text boxes and set the string in the last text box to whatever you want. You should change the code to do something useful though. It's possible that there may be syntax errors, but i can't check that here.
Hi,
You are really my saviour! Been stucked for so many days.
yes I tried with the blalala message and it works when I click my push button. Thanks. Now I am trying to do that to add the sum of the 2 inputs. I believe I am very near but not sure where did I go wrong.
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
hBox2 = handles.edit2;
hBox3 = handles.edit3;
hBox4 = handles.edit4;
val2 = get(hBox2,'string'); %now has the string in Box2
val3 = get(hBox3,'string'); %now has the string in Box3
val4 = val2 + val3;
set(hBox4,'string' val4);
Upon getting this, how do I link it with the toolbox?? This is the more difficult part I guess.
Hi Sorry,
I just realised I should set val1 and val2 as integers instead of string. Will try that out but I'm gonna go for my dinner soon. Not sure which part of the world are you in but I am really thankful for all your help. Will continue to try later or tomorrow and hopefully you are willing to continue to help me.
Thanks once again.
God Bless.
You should be able to call any function you need from the toolbox from inside the pushbutton callback.
Hi,
I am trying to apply the fuzzy logic toolbox onto the GUI. I've tried coding the push button as follows:
hBox2 = handles.edit2;
hBox3 = handles.edit3;
hBox4 = handles.edit4;
val2 = get(hBox2,'string'); %now has the string in Box2
val3 = get(hBox3,'string'); %now has the string in Box3
val2dbl = str2double(val2);
val3dbl = str2double(val3);
val4 = readfis('genes'); % reading into my fuzzy toolbox that I've created
evalfis([val2dbl val3dbl],val4); %evaluating the inputs
set (hBox4,'string',val4); %set the evaluated answer ono edit text 4
I get the following error message
??? Error using ==> set
Conversion to double from struct is not possible.
Error in ==> genes>pushbutton1_Callback at 155
set (hBox4,'string',val4);
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> genes at 44
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.
Do you know the reason??
you probably want to do something like:
Hi there,
When i try to run the GUI, I get the following error:
??? Index exceeds matrix dimensions.
??? Error using ==> struct2handle
Error while evaluating uicontrol CreateFcn
??? Index exceeds matrix dimensions.
??? Error using ==> struct2handle
Error while evaluating uicontrol CreateFcn
??? Index exceeds matrix dimensions.
??? Error using ==> struct2handle
Error while evaluating uicontrol CreateFcn
When I click the pushbutton with 2 inputs, they talk abt subsindex.
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'struct'.
??? Error while evaluating uicontrol Callback
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'struct'.
??? Error while evaluating uicontrol Callback
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'struct'.
??? Error while evaluating uicontrol Callback
Here is my toolbox data if it helps.
name: 'genes'
type: 'mamdani'
andMethod: 'min'
orMethod: 'max'
defuzzMethod: 'centroid'
impMethod: 'min'
aggMethod: 'max'
input: [1x2 struct]
output: [1x1 struct]
rule: [1x7 struct]
Once again pls pardon my ignorance. Programming has always been my achilles heel. Thanks gazillions for your contribution and help.
Hey,
I managed to solve the problem. Thanks alot. Moving on to do the reverse, that is with a required output, I need to retrieve the sets of possible values of inputs. I will need to use one of the search technique and 1 possible way is simulated annealing. Not sure if you are familiar with these search techniques. Will do research on that and let u know if i need help in Matlab agian.
Thanks alot for your help.
Sorry that I've gotta trouble you again. I've tried reading up the matlab help menu on simulated annealing but doesnt seem to understand how to apply into my project. Are you familiar with it?