Callback error and creation of callback
Info
This question is closed. Reopen it to edit or answer.
Show older comments
Hi,
I have a problem I create a GIU. And I have 4 buttons. Each callback should work with different equation comming from outside. How I should write it? Please, help me!

5 Comments
Jan
on 29 May 2019
The question is not clear yet. What does "coming from outside" mean? What exactly is "each callback work with an equation"?
What is the purpose of calculate here? Where does the input a come from? What should happen with the output of the functions?
Please post the code as text, not as screenshot, such that we can use it to post an answer.
Isperih Daulov
on 29 May 2019
Geoff Hayes
on 29 May 2019
Isperih - are your myfunction functions (the four that you show above) defined in m-files? Or are they in your GUIDE m-file only?
Looking at one of your callbacks
function pushbutton7_Callback(hObject, eventdata, handles)
handles=guidata(hObject);
calculate myfunctionmd(RA,a,x)
MD=(RA*2*38.8^3)/(2*38.8^3+3*38.8*a+a^3)/(38.8-a)^2*a/(6*2.1*10^4*0.2083*38.8)*(a/(2*38.8+a))^0.5
end
end
you have
calculate myfunctionmd(RA,a,x)
which may or may not be a comment. If it is, then prefix it with %
% calculate myfunctionmd(RA,a,x)
You then have
MD=(RA*2*38.8^3)/(2*38.8^3+3*38.8*a+a^3)/(38.8-a)^2*a/(6*2.1*10^4*0.2083*38.8)*(a/(2*38.8+a))^0.5
end
end
but nowhere have you indicated where the RA or a variables are defined. Does the user enter them into the GUI? Why do you have two end keywords?
Note that if your functions are defined in separate files, then you just call the functions from within the body of your callbacks making sure to pass in the parameters to the function.
Isperih Daulov
on 29 May 2019
Jan
on 31 May 2019
@Isperih Daulov: Sorry, your posted pseudo-code is too confusing for me. Mixing Matlab with some clear text messages like this is not useful:
calculate myfunctionmac(RA,a,x)
>> x = 0:deltaa
plot
use Mac
end
if x=(a to38.8)
use Mbc
end
I cannot guess, what "use Mbc" means. "if x=(a to38.8)" is not clear also.
calculate myfunctionmd(RA,a,x)
MD=(RA*2*38.8^3)/(2*38.8^3+3*38.8*a+a^3)/(38.8-a)^2*a/(6*2.1*10^4*0.2083*38.8)*(a/(2*38.8+a))^0.5
Here I cannot know, what a and x are.
In consequence, trying to convert your message to Matlab would be based on guessing what you might need. But guessing is not the correct way for scientific work on universities.
I think, that only useful way for you is to learn how to program in Matlab. Beside the Getting Started chapters of the documentation there is Matlab's free "Onramp" also to get familiar with the basics (ask an internet search engine for the link).
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!