how to apply a equation to specific row ranges of a vector?
1 view (last 30 days)
Show older comments
Philippe Corner
on 27 Dec 2018
Edited: madhan ravi
on 28 Dec 2018
If I have two vectors vp and vs, and I want to obtain a vector E which corresponds to this formula:
E = (d*(vs.^2).*(3*(vp.^2))./(vp.^2))./10000;
How could I obtain vector E varying d values with
d1 = 1; %for 1-3 rows
d2 = 2; %for 4-8 rows
d3 = 3; %for 9-10 rows
and obtain
E = [7.66525677840456
35.4506940715996
51.0153087814661
515.455370763582
678.584571443203
699.618989835563
864.000069120001
864.000069120001
1296.00010368000
1296.00010368000];
%%
vp = [340.216815000000;570.718050000000;769.256473000000;1176.42951000000;1632.88855600000;2099.99990500000;2099.99990500000;2099.99990500000;2099.99990500000;2099.99990500000];
vs = [159.846351000000;343.757153000000;412.372440000000;926.872313000000;1063.47274800000;1079.82945400000;1200.00004800000;1200.00004800000;1200.00004800000;1200.00004800000];
d1 = 1;
d2 = 2;
d3 = 3;
E = (d*(vs.^2).*(3*(vp.^2))./(vp.^2))./10000;
0 Comments
Accepted Answer
Jacob Shulman
on 27 Dec 2018
Edited: madhan ravi
on 28 Dec 2018
for i=1:10
if i<=3
E(i) = (d1*(vs(i)^2)*(3*(vp(i)^2))/(vp(i)^2))/10000;
elseif i<=8
E(i) = (d2*(vs(i)^2)*(3*(vp(i)^2))/(vp(i)^2))/10000;
else
E(i) = (d3*(vs(i)^2)*(3*(vp(i)^2))/(vp(i)^2))/10000;
end
0 Comments
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!