Interpolation values from a table

20 Ansichten (letzte 30 Tage)
Tomás Costa
Tomás Costa am 9 Sep. 2019
Kommentiert: Andrea am 5 Dez. 2024
Hi guys, i wonder if anyone can help me! Im trying to intepolate values from a table that i load on to matlab but i dont understand what is the thing that i am doing wrong, can someone help me? Here is my code:
Screenshot 2019-09-09 at 17.55.35.png
Screenshot 2019-09-09 at 17.55.24.png
Screenshot 2019-09-09 at 17.55.08.png
I didnt put the whole code on here because i dont think it is necessary! Basically i got the areatemp1 file with has values for areas mach and temperatures and i want to interpolate to get a mach value after calculating a Area value. if anyone could help me, it would be great
  4 Kommentare
Dheeraj Singh
Dheeraj Singh am 12 Sep. 2019
Please check the variable type of T.Area . You can print the variable to see if it is of expected type or not. You can refer to the documentation of interp1 to see the expected type of T.Area.
Hope this helps.
Tomás Costa
Tomás Costa am 12 Sep. 2019
T.Area is a cell array of 31x1. Basically i have a table called 'areatemp1' which has values of area, mach number and temperatures. What im calculating is an area and i want to use that calculated area to interpolate on the table and export the values for mach number and temperature. I can do everything but once i get to the interpolation this error comes up:
Error using interp1>reshapeAndSortXandV (line 414)
X must be a vector of type double or single.
Error in interp1 (line 93)
[X,V,orig_size_v] = reshapeAndSortXandV(varargin{1},varargin{2});
Error in Tese (line 51)
machs = interp1(T.Area, T.Mach, dif); %array of viscosities the same size as temperature

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jon
Jon am 12 Sep. 2019
Bearbeitet: Jon am 12 Sep. 2019
If T.area is a cell array, and maybe T.Mach is also a cell array you must first turn them into ordinary MATLAB vectors, (n by 1 or 1 by n arrays) before interpolating. So, for example you could do something like
area = cell2mat(T.Area)
Mach = cell2mat(T.mach)
machs = interp1(area,mach,dif);
or perhaps more compactly
machs = interp1(cell2mat(T.area),cell2mat(T.mach),dif)
  6 Kommentare
Jon
Jon am 17 Sep. 2019
Did this answer your question? In the end what was causing the wrong number of arguments error?
Andrea
Andrea am 5 Dez. 2024
I can't speak for Tomas, but Jon your answer helped a lot! Thank you.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Produkte


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by