- Comment out A = double(A) and observe all the outputs in symbolic variables
- Provide values to A before double A and see the values in the numeric form, by using subs function
I keep getting the following error "Unable to convert expression into double array" for the code given below, please help
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
THE ERROR:
INPUT:
clear all
clc
syms x1 x2 y1 y2
Q=input('enter the quadratic form Q(x1,x2):');
a11=(1/2)*diff(diff(Q,x1),x1);
a22=(1/2)*diff(diff(Q,x2),x2);
a12=(1/2)*diff(diff(Q,x1),x2);
A=[a11 a12; a12 a22]
A=double(A)
disp('Matrix of Q is')
%disp('Orthogonal matrix (N) reduces A to diagonal matrix D : ')
[N D]=eig(A)
X=[x1;x2];
Y=[y1;y2];
disp('The canonical quadratic form of Q is')
Qy=transpose(Y)*D*Y;
Qy=vpa(Qy,4)
disp('The orthogonal transformation (X=NY) is')
X=vpa(N*Y,4)
0 Commenti
Risposte (1)
Sriram Tadavarty
il 30 Lug 2020
Hi Ruban Karthik,
The issue you observe is due to the conversion of symbolic variables to double.
For the input provided, the differential equation contains symbolic variables, thus, it can't be converted to double. Once the symbolic variables are provided with values, you can get rid of the error.
Two suggestions to overcome this:
Hope this helps.
Regards,
Sriram
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!