How to assign pair of values to a single aeeay in the matrix using two different vectors

34 次查看(过去 30 天)
fsine=50e6:0.4e9:3e9;
Vp=0:0.5:3;
I need to form a matrix such that columns correspons to different Vp for a single fsine.
the first column should be for fsine=50e6 for all values for Vp and second column should be fsine=50e6+0.1e9 for all values in Vp
The final vector should be have 7 rows and 8 columns.

回答(2 个)

sai charan sampara
sai charan sampara 2024-6-30,7:51
Hi Yogesh
The following code might help you:
fsine=50e6:0.4e9:3e9
fsine = 1x8
1.0e+09 * 0.0500 0.4500 0.8500 1.2500 1.6500 2.0500 2.4500 2.8500
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Vp=0:0.5:3
Vp = 1x7
0 0.5000 1.0000 1.5000 2.0000 2.5000 3.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
M=zeros(7,8);
for idx1=1:7
for idx2=1:8
M(idx1,idx2)=sin(fsine(idx2)*Vp(idx1));
end
end
M
M = 7x8
0 0 0 0 0 0 0 0 -0.4668 0.9423 -0.9201 0.4119 0.3139 -0.8739 0.9723 -0.5571 0.8256 0.6309 -0.7208 -0.7507 0.5960 0.8497 -0.4548 -0.9253 -0.9935 -0.5200 0.3554 0.9562 0.8179 0.0476 -0.7595 -0.9797 0.9316 -0.9790 0.9992 -0.9919 0.9572 -0.8960 0.8101 -0.7018 -0.6543 -0.1354 0.4274 0.8516 0.9997 0.8237 0.3806 -0.1859 0.2256 0.8883 -0.6644 -0.5600 0.9411 0.0951 -0.9881 0.3931
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
  1 个评论
Chuguang Pan
Chuguang Pan 2024-6-30,8:35
fsine = 50e6:.4e9:3e9;
Vp = 0:.5:3;
M=sin(Vp.'*fsine)
M = 7x8
0 0 0 0 0 0 0 0 -0.4668 0.9423 -0.9201 0.4119 0.3139 -0.8739 0.9723 -0.5571 0.8256 0.6309 -0.7208 -0.7507 0.5960 0.8497 -0.4548 -0.9253 -0.9935 -0.5200 0.3554 0.9562 0.8179 0.0476 -0.7595 -0.9797 0.9316 -0.9790 0.9992 -0.9919 0.9572 -0.8960 0.8101 -0.7018 -0.6543 -0.1354 0.4274 0.8516 0.9997 0.8237 0.3806 -0.1859 0.2256 0.8883 -0.6644 -0.5600 0.9411 0.0951 -0.9881 0.3931
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

请先登录,再进行评论。


Voss
Voss 2024-6-30,15:34
编辑:Voss 2024-6-30,15:46
fsine=50e6:0.4e9:3e9;
Vp=0:0.5:3;
result = repmat(Vp(:),1,numel(fsine))
result = 7x8
0 0 0 0 0 0 0 0 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 0.5000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.5000 1.5000 1.5000 1.5000 1.5000 1.5000 1.5000 1.5000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.0000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 2.5000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000 3.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>

类别

Help CenterFile Exchange 中查找有关 Geology 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by