how to apply a equation to specific row ranges of a vector?
2 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
採用された回答
Jacob Shulman
2018 年 12 月 27 日
編集済み: madhan ravi
2018 年 12 月 28 日
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 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!