How to do If, Then, and Edit Field Text?

18 vues (au cours des 30 derniers jours)
Jennifer Norton
Jennifer Norton le 18 Avr 2019
I am working with Matlab app designer and I am creating an app to calculate the dot product (it is for a class). I was wondering if there was a way once the product is caluclated, to have a text box display whether it is acute, obtuse, or orthogonal where it says "These Vectors are"? I can make a message box appear but I would prefer if I could keep everything on the same screen. So if the product is greater than zero, how do I make the text box display "Acute" using an If statement?
This is what I did for the message box to pop up:
if (app.ProductEditField.Value > 0)
msgbox('These Vectors are Acute')
elseif (app.ProductEditField.Value < 0)
msgbox('These Vectors are Obtuse')
elseif (app.ProductEditField.Value == 0)
msgbox('These Vectors are Orthogonal')
end
This is what I tried to do:
if (app.ProductEditField.Value > 0)
app.TheseVectorsareEditField = 'Acute'
elseif (app.ProductEditField.Value < 0)
app.TheseVectorsareEditField = 'Obtuse'
elseif (app.ProductEditField.Value == 0)
app.TheseVectorsareEditField = 'Orthogonal'
end

Réponses (1)

Geoff Hayes
Geoff Hayes le 19 Avr 2019
Jennifer - you haven't said what your error is (if there is one) or whether the problem is that no text appears in the expected field. You probably just need to assign the string to the appropriate member/property of the edit text field...so your code could look like
if (app.ProductEditField.Value > 0)
app.TheseVectorsareEditField.Value = 'Acute'
elseif (app.ProductEditField.Value < 0)
app.TheseVectorsareEditField.Value = 'Obtuse'
elseif (app.ProductEditField.Value == 0)
app.TheseVectorsareEditField.Value = 'Orthogonal'
end
The only difference (from your code) is the inclusion of .Value for the assignment to the app.TheseVectorsareEditField control

Catégories

En savoir plus sur Text Analytics Toolbox 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