Perform elementwise substitution of vector of scalars into vector of equations.
조회 수: 4 (최근 30일)
이전 댓글 표시
Hi all,
I have a vector (t) of 1000 scalars and corresponding vector (d) of equations of (t) , I wanted to substitut
e each element of t in the corresponding equation.
I used for loop but it seems that it substitute all the values in (t) into first elemnt of (d) and then to second elemnt ans so on.. which will let the resulted vector be 1*(1000)^2 instead of 1*1000.
this is my try (I used simplified example):
a=[ 1;2;3;4;5];
syms t
v=int(a,t)
d=int(v,t)
t=[0.2;0.3;0.4;0.5;0.6];
dd=subs(d,t)
댓글 수: 0
답변 (1개)
Swetha Polemoni
2021년 3월 4일
Hi
It is my understanding that you want substitute every value of t in each equation d.
d =
t^2/2
t^2
(3*t^2)/2
2*t^2
(5*t^2)/2
You may find the following code snippet useful.
a=[ 1;2;3;4;5];
syms t
v=int(a,t)
d=int(v,t)
t=[0.2;0.3;0.4;0.5;0.6];
dd=zeros(5,5);
for i =1:length(t)
dd(i,:)=subs(d,t(i));
end
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!