Perform elementwise substitution of vector of scalars into vector of equations.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Swetha Polemoni
am 4 Mär. 2021
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
Siehe auch
Kategorien
Mehr zu Matrix Indexing 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!