필터 지우기
필터 지우기

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

조회 수: 34 (최근 30일)
Yogesh
Yogesh 2024년 6월 30일 7:43
편집: Voss 2024년 6월 30일 15:46
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