Function vpa in matlab GUI

2 vues (au cours des 30 derniers jours)
Olaniyi Olufunmilayo
Olaniyi Olufunmilayo le 13 Mai 2017
hi guys,i have been trying to get this piece of code to work for a couple of hours now but to no avail. It will be more appreciated if i can get help. This works fine when i try to display on the command window but doesn't work when i do the same on the gui. a sample of the code is shown below;
syms Pw1
Pw=((3*M)+sind(IF))*Pw1+(sind(IF)-M)*(sqrt(((Y-Pw1)^2)+Z)+X)-(4*BC*R*sind(IF))+(4*CH*cosd(IF));
solPw1 = solve(Pw,Pw1);
set(handles.PW_Breakout1,'String',vpa(solPw1));

Réponse acceptée

John D'Errico
John D'Errico le 13 Mai 2017
Your problem is that vpa does NOT create a string.
vpa(pi,50)
ans =
3.1415926535897932384626433832795028841971693993751
whos ans
Name Size Bytes Class Attributes
ans 1x1 8 sym
As you can see, vpa creates a number, that is still a symbolic value. NOT a string.
What do you need to stuff a gui field? A STRING.
char(vpa(pi,50))
ans =
'3.1415926535897932384626433832795028841971693993751'
What did char do? Take a look.
  1 commentaire
Olaniyi Olufunmilayo
Olaniyi Olufunmilayo le 13 Mai 2017
Thanks a lot john, it works perfectly now

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by