need help in this
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ali Najem
am 29 Mär. 2020
Kommentiert: Ameer Hamza
am 1 Apr. 2020
Hello everybody
i just have this code:
syms w1 w2 w3 w4 v1 v2 x1 x2 yd
n1=w1*x1+w2*x2;
o1=1/(1+exp(-n1));
o1_der=o1*(1-o1);
%%
n2=w3*x1+w4*x2;
o2=1/(1+exp(-n2));
o2_der=o2*(1-o2);
%%
n3=v1*o1+v2*o2;
o3=(1/(1+exp(-n3)));
o3_der=o3*(1-o3);
e1=(o3-yd);
%%
A1=((o1^2+o2^2)*o3_der^2 +(x1^2+x2^2)*(v1^2)*o1_der^2*o3_der^2+(x1^2+x2^2)*(v2^2)*(o2_der^2)*o3_der^2);
%%
aa=e1*A1;
aw1=diff(aa,w1);
I need to take (aw1) which is derived (aa) respect to (w1) then use it in b.m file for example.. (aw1 is symbolic i mean all values inside are varibals).
The error below occure when i save aw1 as a data and load it in another file and run
(Inputs must be floats, namely single or double.
Error in ode15s (line 150)
odearguments(FcnHandlesUsed, solver_name, ode, tspan, y0, options, varargin);
Error in simple (line 44)
[T1,cox]=ode15s(@(t,y1) Costatesimple(t,y1,u,x1,x2,yd,x1t,e1,w1,w2,w3,w4,v1,v2),tspan2,[0 0 0 0 0 0 0],options);
any help please?
however, it works when i copy all values insied aw1 and paste it in b.m file..
due to the value of aw1 is too long so, i need way to move it to another file without copy and paste
i would you to help in this issue please.
0 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 29 Mär. 2020
When saving aw1 in a.m you need to save all other symbolic variables too
save('filename.mat', 'aw1', 'w1', 'w2', 'w3', 'w4', 'v1', 'v2', 'x1', 'x2', 'yd' );
and then load the file in b.m
load('filename.mat');
Alternatively, you can also try to just save aw1
save('filename.mat', 'aw1')
and then in b.m write
load('filename.mat');
syms w1 w2 w3 w4 v1 v2 x1 x2 yd
For a bit detailed discussion on this topic, refer to Walter's answer and my comments here: https://www.mathworks.com/matlabcentral/answers/513625-how-to-save-a-symbolic-equation-in-a-txt-file#answer_422592
10 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Symbolic Math Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!