MATLAB Answers

0

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

Asked by Jennifer Norton on 18 Apr 2019
Latest activity Answered by Geoff Hayes
on 19 Apr 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

  0 Comments

Sign in to comment.

1 Answer

Answer by Geoff Hayes
on 19 Apr 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

  0 Comments

Sign in to comment.