How to correctly solve cubic spline interpolation?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello All, I need help in cubic spline into matlab.
I am trying this:
a(i,j,k)=interp1(x(j),m-1,x1,x2);
where x(j) is a 1x20 matrix, m=20, n=30, x1=zeros(m), x2=zeros(n)
For the above command I am getting
Wrong number of input arguments
this error. Can anyone help me to correctly model this?
2 Kommentare
Stephen23
am 19 Mai 2016
@adi kul: please edit your question and tell us what the dependent and independent variable are, and which points you want to evaluate the function at.
Antworten (1)
John D'Errico
am 19 Mai 2016
Bearbeitet: John D'Errico
am 19 Mai 2016
To "model it" makes no sense when you talk about an existing piece of software, that is well documented. So I'm not sure what you intend there.
If your goal is to use interp1 to do some sort of interpolation using two independent variables, again, this makes no sense, since interp1 is not designed to take more than one independent variable as an input. Interp1 is NOT a two-dimensional tool. The 1 at the end of the name is a hint that interp1 is a 1 (ONE) dimensional software.
So if you need a tool that can interpolate as a function of two input variables, use a tool like interp2 or griddata or scatterInterpolant.
If for some reason you wish to write something like one of those tools, and want us to write it for you, then I'm sorry, but this site does not do your work for you. Anyway, that answer would take far too long a time to write, essentially a book on the topic. You would need to do some reading about one of the many ways to do interpolation in more than one dimension, and then start writing code.
Anyway, it is rarely a good idea to re-write existing high quality software, written by a professional in that art of mathematics.
If your wish is something completely different, then you need to explain what your needs are, and do so far more clearly.
4 Kommentare
John D'Errico
am 20 Mai 2016
Bearbeitet: John D'Errico
am 20 Mai 2016
It would be easier if I did not have to ask so many questions, instead you could be more proactive with such clearly necessary information. Is this perhaps DCSINT and DCSVAL that you are using, from the IMSL library? OR is this DCSINT from NETLIB/TOMS that you are using?
If the IMSL routine, DCSINT creates a spline using the not-a-knot end conditions, and DCSVAL evaluates that spline?
Interestingly, finding documentation for any of these codes online seems surprisingly difficult. All of the links seem to be broken. Perhaps that is a signal that IMSL is itself no longer supported.
Anyway, the first problem is that you are trying to write MATLAB as if it was fortran. In fortran, you pass in the entire argument list, both input and return arguments on the right. In MATLAB, the return arguments are on the left. So, it appears that x2 in the call to DCSVAL should be the return argument.
I'll need to find documentation for DCSINT and DCSVAL to know.
Siehe auch
Kategorien
Mehr zu Interpolation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!