Hi, I have one set of data that I need to compare it with different size of data. So, as it stated in this code below, the threshold will be 3, 3.5, 4, 4.5 ..... I have to compare each threshold with all available data in variable GtrecMRCG2 then get its index. after all data compared, I need to check it with remaining threshold in variable thresholdVAR.
I wrote this based on my understanding. but it doesn't work because the dimension is mismatched. Thank you so much and big appreciation to those who want to give me advises. :)
threshold = 3;
thresholdVAR=[threshold 0 0 0 0 0 0 0 0];
GtrecMRCG2= [ 5 8 9 6 2 5 2 4 6 3 8 9 11];
for ii=1:9
thresholdVAR(ii+1:end)= thresholdVAR(ii)+ 0.5;
end
for idxm=1:length(thresholdVAR)
for idxn = 1:length(GtrecMRCG2)
idxalarmMRCG (1:length(thresholdVAR),1:length(GtrecMRCG2))= find(GtrecMRCG2(idxm,idxn)>=thresholdVAR(idxm,idxn));
end
end

4 件のコメント

Jan
Jan 2016 年 4 月 28 日
Please post the complete error message.
Your description is a little bit vague and the code does not run. Therefore I doubt that the given information allows to solve the problem in the way you want.
In the first loop you overwrite the elements multiple times. Perhaps all you want cumsum?
Tifani Utami
Tifani Utami 2016 年 4 月 28 日
yes I am trying to construct cumsum which does not come from matlab function. the code above, is just an example. I'm working with larger and dynamic size data. I found this solution in other discussion which kind of similar to my problem. I've tried to modified them and still
??? Error using ==> lt
Matrix dimensions must agree.
Error in ==> coba2 at 19
is_greater_equal = find( thresholdVAR(idxm:sza(1),idxn:sza(2)) <
GtrecMRCG2(1:sza(1),1:sza(2)));
code:
threshold = 3;
thresholdVAR=[threshold 0 0 0 0 0 0 0 0];
GtrecMRCG2= [ 5 8 9 6 2 5 2 4 6 3 8 9 11];
for ii=1:9
thresholdVAR(ii+1:end)= thresholdVAR(ii)+ 0.5;
end
sza = size( thresholdVAR );
for idxm=1:length(thresholdVAR)
for idxn = 1:length(GtrecMRCG2)
is_greater_equal = find( thresholdVAR(idxm:sza(1),idxn:sza(2)) < GtrecMRCG2(1:sza(1),1:sza(2)));
end
end
CS Researcher
CS Researcher 2016 年 5 月 1 日
Not exactly sure what you are trying to achieve but you should see the line with the code:
find( thresholdVAR(idxm:sza(1),idxn:sza(2)) < GtrecMRCG2(1:sza(1),1:sza(2)));
Your thresholdVAR and GtrecMRCG2 are not 2D matrices. They both are 1D vectors.
Also, you don't need a loop to initialize the thresholdVAR. You can just do this:
thresholdVAR = 3:0.5:7;
Tifani Utami
Tifani Utami 2016 年 5 月 2 日
example first value of threshold. when threshold is 3, compare it with the value which in GtrecMRCG2 variable. find the index containing value that greater equal than GtrecMRCG2.
is_greater_equal will be [ 1 2 3 4 6 8 9 10 11 12 13]
then move to the next threshold which is 3.5
is_greater_equal = [ 1 2 3 4 6 8 9 10 11 12 13]
the process will keep going until all value which in GtrecMRCG2 compared with last threshold. my question is how to manipulate the output or to construct a new matrices as a result of comparison between two different matrices length.

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

 採用された回答

Ilham Hardy
Ilham Hardy 2016 年 5 月 2 日

0 投票

Something like this?
thresholdVAR = 3:0.5:7;
GtrecMRCG2= [ 5 8 9 6 2 5 2 4 6 3 8 9 11];
% preallocate
DesMat = zeros(length(thresholdVAR),length(GtrecMRCG2));
for oneL = 1:length(thresholdVAR)
[r,c,v] = find(GtrecMRCG2>thresholdVAR(oneL));
DesMat(oneL,c) = GtrecMRCG2(c);
end

1 件のコメント

Tifani Utami
Tifani Utami 2016 年 5 月 3 日
thanks a lot. I finally able to use the result to find its average value.

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by