필터 지우기
필터 지우기

How to change the length and the values of a vector?

조회 수: 1 (최근 30일)
Enrica Brunetti
Enrica Brunetti 2020년 9월 2일
댓글: Enrica Brunetti 2020년 9월 2일
I have a vector whose length = 503. I want to obtain a vector whose length is 100 or its multiple. I suppose I have to use some proportion, but I don't know how.
I think also the values of vector must change, but in which way? I think with the mean.
[madhan ravi: removed huge amount of data]

채택된 답변

madhan ravi
madhan ravi 2020년 9월 2일
n = numel(vector);
V = reshape([vector, nan(1, 1e2 - mod(n, 1e2))], [], 1e2);
Wanted = nanmean(V)
%or
Wanted = mean(V, 'omitnan')
%% or depending on which suits you the best
V = reshape([vector, nan(1, 1e2 - mod(n, 1e2))], 1e2, []);
Wanted = nanmean(V, 2)
%or
Wanted = mean(V, 2, 'omitnan')
  댓글 수: 3
madhan ravi
madhan ravi 2020년 9월 2일
So , what do you propose?
Enrica Brunetti
Enrica Brunetti 2020년 9월 2일
Is there any way to obtain the average within 100 values?
Or is it correct if I use the function imresize( vector, [1 100]);? In this way I get a vector of 100 values, even if I don't understand with which operations it obtains them.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by