Storing values using csapi (spline functin)
Afficher commentaires plus anciens
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.
Réponses (2)
Sean de Wolski
le 24 Fév 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 commentaires
Mauricio Marulanda
le 24 Fév 2012
Sean de Wolski
le 24 Fév 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
le 24 Fév 2012
Sean de Wolski
le 24 Fév 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
le 24 Fév 2012
save those four lines of code as csapiCell somewhere on the MATLAB path.
Mauricio Marulanda
le 24 Fév 2012
Mauricio Marulanda
le 24 Fév 2012
Sean de Wolski
le 24 Fév 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
le 24 Fév 2012
Sean de Wolski
le 24 Fév 2012
If called correctly it will take a cell array:
doc csapi
Mauricio Marulanda
le 24 Fév 2012
Mauricio Marulanda
le 27 Fév 2012
0 votes
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!