Taking punctual values of array

3 ビュー (過去 30 日間)
vincenzo violi
vincenzo violi 2021 年 2 月 16 日
コメント済み: Just Manuel 2021 年 3 月 2 日
Hello everyone!
I need to take punctual values of array of 1024 values .
Precisly I need to take 64,256,1024. The goal is , instead of considering a big array of 1024 values, consider a small array of 3, where the first value is the 64th values, second the 256th and third the 1024th.
the code is the following:
LRIS=zeros(length(d1range),3);
LRIS5=zeros(length(d1range),3);
SNRRIS=zeros(length(d1range),3);
ToffRIS1=zeros(length(d1range),3);
for k = 1:length(d1range)
.
.
.
.
for j=1:3 %%per ciascun valore di j corrispondente a 1,2,3 -> 64, 256, 1024
for z = 1:n(j) %%ti calcoli i valori di attenuazione su sommatoria
LRIS(k,z)=((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))));
end %HERE
end
LRIS5(k,:)=LRIS(k,:).^(-2);
SNRRIS(k,:)=(Pt./LRIS5(k,:)./N2);
ToffRIS1(k,:)=Dn./(B.*log(1+(SNRRIS(k,:)))) ;
The problem is, that LRIS should have 81x3, where 81 is derived from k lenght, 3 should be the punctual values of 64,256, 1024, but at the end of zed for statment ( here )
it has 81x1024. Where am I wrong?
  3 件のコメント
vincenzo violi
vincenzo violi 2021 年 2 月 16 日
sorry, n=[64.256.1024]
vincenzo violi
vincenzo violi 2021 年 2 月 16 日
the goal of for j=1:3 and for z= 1:n(j) is to take the 64th , 256th and 1024th value making a 81x3.
That is what I supposed to do, I don't know if it is correct :)

サインインしてコメントする。

回答 (2 件)

Just Manuel
Just Manuel 2021 年 2 月 16 日
I assume you have defined n somewhere in that manner:
n = [64, 256, 1024];
in this line
LRIS(k,z)=((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))));
you assign LRIS(k,1:n), meaning when j=3 you assing LRIS(k,1:1024)
there's your size of 81x1024 coming from.
change your code to something like
LRIS(k,j)= x;
I assume from the comment that you want to have a sum of your calculation, sum it up like this:
n = [64, 256, 1024];
for k = 1:length(d1range)
for j=1:3 %%per ciascun valore di j corrispondente a 1,2,3 -> 64, 256, 1024
for z = 1:n(j) %%ti calcoli i valori di attenuazione su sommatoria
LRIS(k,j) = LRIS(k,j) + ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))));
end
end
end
  7 件のコメント
Just Manuel
Just Manuel 2021 年 2 月 16 日
編集済み: Just Manuel 2021 年 2 月 16 日
Well, we have two questions now.
1. Your original question: why your LRIS had the size 81x1024.
This one we solved.
2. Your follow-up question: why all the calculation are the same for three columns
This is where I'm not entirely clear what you are trying to do.
  • You say, you want to calculate ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k)))))) for the 64th, the 256th and the 1024th element of your source data respectively.
  • You have a loop from 1 to 64, 256, 1024 respectively (for z = 1:n(j)). However, i see no other use of the iteration variable z than the one that was causing the size of 81x1024 of LRIS
  • You supplied the additional information ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))))x64 in your last comment. Do you mean ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))))*64 ?
We'll need to know what your big array of 1024 values is, and what you want to calculate for your specific samples (64, 256 and 1024).
If you really meant ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))))*64, then go with:
n = [64, 256, 1024];
for k = 1:length(d1range)
for j=1:3 %%per ciascun valore di j corrispondente a 1,2,3 -> 64, 256, 1024
LRIS(k,j) = LRIS(k,j) + ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k)))))) * n(j);
end
end
I suspect you want do do something like this:
% i don't know what your big array is, so i'll do random
big_array = rand(1,1024);
d1range = 10:3:250;
n = [64, 256, 1024];
for k = 1:length(d1range)
for j=1:3 %%per ciascun valore di j corrispondente a 1,2,3 -> 64, 256, 1024
%%ti calcoli i valori di attenuazione su sommatoria
% calculation depends on k and on the sample in your big array
LRIS(k,j) = LRIS(k,j) + calculation(k,big_array(n(j)));
end
end
Just Manuel
Just Manuel 2021 年 3 月 2 日
Please accept the answer, if it was of use to you.
Cheers
Manuel

サインインしてコメントする。


KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 16 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 16 日
"The problem is, that LRIS should have 81x3, where 81 is derived from k lenght, 3 should be the punctual values of 64,256, 1024, but at the end of zed for statment ( here )
it has 81x1024. Where am I wrong?"
Yes, the problem with the column number, if you choose any number of z, let's say 200, loop iterate for one time as well, then also it will generate 1 to 199 columns.
More example
>> A(1,3)=4
A considering 1 row, 3 cloumns. I have not mentioned the number of columns anywhere, but MATLAB creates an A with a maximum of 3 columns, those undefined elements are assigned as zeros
A =
0 0 4
Same in the case of LRIS(k,z), here z=1:1:n(j), where n=n=[64,256,1024];
Where the maximum z is 1024, MATLAB makes the total number of columns as 1024. Because if you define any matrix element with1024 columns, it presumned that there are other column numbers as well (less than that).
Hence it produces LRIS as 81x1024
Hope you can modify accordingly as per desired requirements.
  3 件のコメント
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 16 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 16 日
Yes, if you want to fill any column number with special value, lets say column number 4 (all rows) with 64 value
mat(:,4)=64*ones(number_of_rows,1);
More clarification on the question will actually help to answer.
vincenzo violi
vincenzo violi 2021 年 2 月 16 日
Sorry , I was not that clear.
I need to fill the three columns with the values derived by formula listed above :
LRIS(k,j) = LRIS(k,j) + ((sqrt((1/(Lsrpw051(k)*Lrdpw052(k))))));
:)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by