How i can i Ensure that my 2 vectors have the same size?!
2 ビュー (過去 30 日間)
古いコメントを表示
I have the following code (below) and want that DAPEAK_IN (1X86) and DAPEAK_OUT (1X63) have the same size i tried using this code
%Calculate daily averages from CleanPeaks, Max Threshold set to 2000, where 2 is values in and 4 is values out
DAPeaks_in = DailyAverageNY(CleanPeaks_in,2,5,100);
DAPeaks_out = DailyAverageNY(CleanPeaks_out,4,5,100);
DAPeaks_in = DAPeaks_in(1:size(DAPeaks_out,1),:); % adjust the size of DAPEAKS_IN to DAPEAKS_OUT and vice versa
DAPeaks_out = DAPeaks_out(1:size(DAPeaks_in,1),:)
however the stil have the same size as before DAPEAK_IN (1X86) and DAPEAK_OUT (1X63) - any suggestion on how to achevie this FYI i have not tried any function for it
best regards - Amil Ali
0 件のコメント
採用された回答
Jon
2023 年 5 月 1 日
編集済み: Jon
2023 年 5 月 1 日
If you want DAPEAK_in to have the same dimension as DAPEAK_out then I assume you want both of them to have the same dimesion as the smallest of the two. Otherwise you would somehow have to add values, or just put zeros to lengthen the shorter one. You could do something like this (I have assumed, as in your description that both are row vectors):
%Calculate daily averages from CleanPeaks, Max Threshold set to 2000, where 2 is values in and 4 is values out
DAPeaks_in = DailyAverageNY(CleanPeaks_in,2,5,100);
DAPeaks_out = DailyAverageNY(CleanPeaks_out,4,5,100);
% determine number of elements in the shorter one
nKeep = min(numel(DAPeaks_in),DAPeaks_out);
% adjust the size of DAPEAKS_IN to DAPEAKS_OUT and vice versa
% set them both to the same length
DAPeaks_in = DAPeaks_in(1,1:nKeep);
DAPeaks_out = DAPeaks_out(1:nKeep);
2 件のコメント
Stephen23
2023 年 5 月 1 日
I guess you intended:
nKeep = min(numel(DAPeaks_in),numel(DAPeaks_out));
% ^^^^^^ ^
その他の回答 (1 件)
KALYAN ACHARJYA
2023 年 5 月 1 日
編集済み: KALYAN ACHARJYA
2023 年 5 月 1 日
Hope I have understand the question- Here is the example
DAPEAK_IN=randi([1,100],[1,randi(200)]); %Random data
size(DAPEAK_IN)
DAPEAK_OUT=randi([1,100],[1,randi(200)]); %Random data
size(DAPEAK_OUT)
if size(DAPEAK_IN,2)>size(DAPEAK_OUT,2)
DAPEAK_IN=DAPEAK_IN(1:size(DAPEAK_OUT,2));
else
DAPEAK_OUT=DAPEAK_OUT(1:size(DAPEAK_IN,2));
end
size(DAPEAK_IN)
size(DAPEAK_OUT)
The size can also be done with extrapolate, actually representing the data set. Here I have foreced the data in particular range, the remaining will be lost which may be meningful data, please look on that point.
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!