How can I run multiple symbolic functions simultaneously
이전 댓글 표시
Dear all,
I have symbolic Matlab codes and I want to run three symbolic functions simultaneously. But I noticed that the main program does not run correctly. I need to find the difference UXT(k)-WK(k) but it gives only values of WK(k). I add the codes. Any help would be appretiated. Thanks in advance.
function [y]=karalamax()
clc
clear all
syms x t epsilon eta zeta xsi N m k tau
[WK] =worker1k()
Y=[];
UXT=[];
for k=1:8
WK(k)
x=1;
tau=1;
epsilon=1;
UXT=(k-1)*tau*epsilon*x;
UXT(k)=UXT
Y(k)=UXT(k)-WK(k)
% YY(k)=(UXT(k)-WK(k))
end
this is my main program.
function [WK] =worker1k(WK1,WK2)
clc
clear all
syms x t epsilon eta zeta xsi N m tau
[WK1,WK2] =symk();
% [FK]=worker3();
% syms x t alpha beta epsilon tau eta zeta xsi N m k
WK=[];
FK=[];
alpha=1/2;
beta=-1/2;
N=3;
for k=1:6
x=1;
tau=1;
epsilon=1;
FK(k)=epsilon*x*((k+1)*tau+1);
%
% FKKK(k)=subs(fk,{x,tau,epsilon,N},{5,0.02,0.001,50}) ;
% FKK=simplify(FKKK(k));
% FK(k)=eval(FKK);
WK(1)=WK1;
WK(2)=WK2;
% WK(1)=subs(w0,{x,tau,epsilon,N},{10,1,2,10});
% WK(2)=subs(w1,{x,tau,epsilon,N},{10,1,2,10});
WK(k+2)=-WK(k)+WK(k+1)+FK(k);
end
end
This is the third one
function [WK1,WK2] =symk()
% clc
% clear all
syms f(x) x t epsilon tau eta zeta xsi N m
N=4;
for k=1:6
x=1;
tau=1;
epsilon=1;
alpha=1/2;
beta=-1/2;
w0=epsilon*x*tau;
WK1=w0;
w1=2*epsilon*x*tau;
WK2=w1;
% W1=subs(w0,{x,tau,epsilon,N},{5,0.02,0.001,50});
% WW1=simplify(W1);
% WK1=eval(WW1);
% W2=subs(w1,{x,tau,epsilon,N},{5,0.02,0.001,50});
% WW2=simplify(W2);
% WK2=eval(WW2);
% simplify(WK1)
% simplify(WK2)
% çıkan fonksiyon sonucu command window da yazdım ve direk sayısal
% değerini verdi
end
end
채택된 답변
추가 답변 (1개)
Walter Roberson
2024년 4월 1일
0 개 추천
In order to run three symbolic functions simultaneously, you can use a background pool and parfeval() the execution of each of the functions. Alternately if you have the Parallel Computing Toolbox then you can use parfor or spmd or parfeval
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!