Storing values using csapi (spline functin)
Show older comments
I have been trying to use csapi. This command will work: x = [0 1 2 3]; y = [0 1 2 3]; csapi(x,y); However, I am trying to let x be a cell array. x = {[0 1 2 3] [0 1 2 3]}; y = [0 1 2 3]; Basically I want my "x" to be a table with different values. csapi(x,y); will not work for this case. Is this possible? I appreciate any help.
Answers (2)
Sean de Wolski
on 24 Feb 2012
0 votes
Why not just use a for-loop?
Or you coudl write a wrapper function around csapi that uses a for-loop internally but allows you to call it with a cell array.
Just my $0.02
11 Comments
Mauricio Marulanda
on 24 Feb 2012
Sean de Wolski
on 24 Feb 2012
post the full code of what you tried, it should be something like this:
C = your cell a cell arrasy
for ii = 1:length(C)
result{ii} = csapi(C{ii},y)
end
Mauricio Marulanda
on 24 Feb 2012
Sean de Wolski
on 24 Feb 2012
Still not going to work because csapi doesn;t want cell arrays!
I would recommend writing
out = csapiCell(Cx,y)
for ii = length(Cx):-1:1
out{ii} = csapi(Cx{ii},y);
end
Sean de Wolski
on 24 Feb 2012
save those four lines of code as csapiCell somewhere on the MATLAB path.
Mauricio Marulanda
on 24 Feb 2012
Mauricio Marulanda
on 24 Feb 2012
Sean de Wolski
on 24 Feb 2012
csapiCell the four lines of code I wrote above, if saved as an *.m file will be a wrapper that calls csapi with the contents of each cell. and returns a cell.
Mauricio Marulanda
on 24 Feb 2012
Sean de Wolski
on 24 Feb 2012
If called correctly it will take a cell array:
doc csapi
Mauricio Marulanda
on 24 Feb 2012
Mauricio Marulanda
on 27 Feb 2012
0 votes
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!