Callback error and creation of callback
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
Jan
2019년 5월 29일
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
2019년 5월 29일
Geoff Hayes
2019년 5월 29일
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
2019년 5월 29일
Jan
2019년 5월 31일
@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).
답변 (0개)
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
