How to store an interpolated data to get the mean for each new point in X?

조회 수: 1 (최근 30일)
Pedro Oliveira
Pedro Oliveira 2019년 11월 13일
편집: Prabhan Purwar 2020년 1월 21일
I am trying to find the mean for each point in a series of 16 profiles. The code is as following
a= table2array (DataTot);
b= standardizeMissing(a,nan);
b = reshape(a,[181,4,16]);
for i=1:16
xx= b(:,1,i);
yy=b(:,4,i);
yyc = yy;
[maxHValue, indexAtMaxH] = findpeaks(yyc);
xshift=xx(yyc==max(maxHValue));
xxs=xx - xshift;
xxs = rmmissing(xxs);
yyc = rmmissing(yy);
XYint = interp1(xxs,yyc,-100:1:200);
L(i)= XYint %ERROR
end
When I try to store in L it doesn't allow me to do so(ERROR="unable to perform assignment because the indices on the left side are not compatible with the size of the right side"). Is there a way to find the mean while inside the loop for the interpolated values or should I store it to use the data after the loop?
Thanks for the help.
  댓글 수: 2
David Hill
David Hill 2019년 11월 13일
if the size of XYint changes, you could use a cell array.
L{i}= XYint;
Pedro Oliveira
Pedro Oliveira 2019년 11월 13일
편집: Pedro Oliveira 2019년 11월 14일
It did work, thank you!
but the problem now is how the data from x keep stored. It only store a 1x301 cell. And I lose how to plot the x to y later on with the mean value.

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

답변 (1개)

Prabhan Purwar
Prabhan Purwar 2020년 1월 21일
편집: Prabhan Purwar 2020년 1월 21일
Hey,
The mean of the interpolated values could be found out using the mean() function in the loop.
You may make use of Cell arrays to store variable size datasets as shown in the following code:
L{1,i}=XYint; %y data
L{2,i}=xxs; %x data
L{3,i}=xshift; %x shift
For more information refer to the following links:

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by