Interpolation problem with interp1

์กฐํšŒ ์ˆ˜: 6 (์ตœ๊ทผ 30์ผ)
Manal NOURI
Manal NOURI 2021๋…„ 9์›” 7์ผ
๋Œ“๊ธ€: Manal NOURI 2021๋…„ 9์›” 8์ผ
Hello everyone:)
I have graphic with some missing data, so I interpolated my data vector to fill the gaps but I have this error message " Brace indexing is not supported for variables of this type." and I could not fond the error! So here is the code I used:
for i=1:length(t0)
R{i}=interp1(t{i},R{i},t0,'linear');
end
thanks in advence๐Ÿ˜Š

์ฑ„ํƒ๋œ ๋‹ต๋ณ€

Image Analyst
Image Analyst 2021๋…„ 9์›” 7์ผ
Are t and R cell arrays, tables, or just regular double numerical arrays? If they're just regular numerical arrays, use parentheses, not braces. Please read the FAQ to know when you need to use braces, parentheses, or brackets:
If they are just regular vectors, you don't need a for loop, you can simply do
% t is x, R is y, and t0 are the new x values that you want y values for.
interpolatedY = interp1(t, R, t0, 'linear');
R = interpolatedY; % If you want to replace your existing R, then do this.
  ๋Œ“๊ธ€ ์ˆ˜: 1
Manal NOURI
Manal NOURI 2021๋…„ 9์›” 8์ผ
yes it works perfectly :), thank you for your answer and for the link it's so interesting

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์ถ”๊ฐ€ ๋‹ต๋ณ€ (1๊ฐœ)

Ravi Narasimhan
Ravi Narasimhan 2021๋…„ 9์›” 7์ผ
ํŽธ์ง‘: Ravi Narasimhan 2021๋…„ 9์›” 8์ผ
Not sure what your R vector represents but it seems like you are trying to use a loop to interpolate within a one-dimensional array. This is something Matlab does at the array level itself without the need for a loop.
If you look up help interp1 , there's an example of this.
X = 0:10;
V = sin(X);
Xq = 0:.25:10;
Vq = interp1(X,V,Xq);
plot(X,V,'o',Xq,Vq,':.')
X and V have 11 elements.
Xq and the interpolated Vq have 41 elements.
No looping required.
  ๋Œ“๊ธ€ ์ˆ˜: 1
Manal NOURI
Manal NOURI 2021๋…„ 9์›” 8์ผ
thank you for the explication that you gave me, and for the idea of the plot for both data and their interpolation, I have successfully done it :)

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์นดํ…Œ๊ณ ๋ฆฌ

Help Center ๋ฐ File Exchange์—์„œ Interpolation์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์•Œ์•„๋ณด๊ธฐ

ํƒœ๊ทธ

Community Treasure Hunt

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

Start Hunting!

Translated by