How to save structure data to excel in matlab?

3 vues (au cours des 30 derniers jours)
feng zhao
feng zhao le 8 Avr 2022
Réponse apportée : KSSV le 8 Avr 2022
Here is the code.
I save the solution of the multivariate equation as the structure A1s, which contains the three fields of A1, A2, E2, and the value of A1s.A1 can be seen on the command line, but the three fields of the workspace A1s are all sym type, and the value is not displayed, how to save the value of A1s as excel?
I tried xlswrite, but it doesn't support writing of sym type data.
format compact
x1=600;y1=0;z1=1200;
x2=800;y2=0;z2=-1200;
syms A1 E1 A2 E2
yt=500;zt=500;
i=0;
for xt=-5000:10:0
i=i+1;
eq1=(x1-xt).*(tan(A1)-tan(A2))+((x1-x2).*tan(A2)-(z1-z2));
eq2=(y1-yt).*(tan(A1)-tan(A2))+((x1-x2).*tan(A2)-(z1-z2)).*(tan(E1).*sec(A1));
eq3=(z1-zt).*(tan((A1))-tan((A2)))+((x1-x2).*tan(A2)-(z1-z2)).*tan((A1));
A1s=solve([eq1,eq2,eq3],[A1,A2,E1]);
fprintf('the %dth vector\n',i);
fprintf('A1');
A1s.A1;
end
A1s and A1s.A1 looks like this
>> A1s
A1s =
struct with fields:
A1: [1×1 sym]
A2: [1×1 sym]
E1: [1×1 sym]
>> A1s.A1
ans =
0.13058472475286441634383957631484

Réponse acceptée

KSSV
KSSV le 8 Avr 2022
Read about double, vpasolve.
double(A1s.A1)

Plus de réponses (0)

Catégories

En savoir plus sur Formula Manipulation and Simplification dans Help Center et File Exchange

Produits


Version

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by