Storing values using csapi (spline functin)
Ältere Kommentare anzeigen
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.
Antworten (2)
Sean de Wolski
am 24 Feb. 2012
0 Stimmen
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 Kommentare
Mauricio Marulanda
am 24 Feb. 2012
Sean de Wolski
am 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
am 24 Feb. 2012
Sean de Wolski
am 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
am 24 Feb. 2012
save those four lines of code as csapiCell somewhere on the MATLAB path.
Mauricio Marulanda
am 24 Feb. 2012
Mauricio Marulanda
am 24 Feb. 2012
Sean de Wolski
am 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
am 24 Feb. 2012
Sean de Wolski
am 24 Feb. 2012
If called correctly it will take a cell array:
doc csapi
Mauricio Marulanda
am 24 Feb. 2012
Mauricio Marulanda
am 27 Feb. 2012
0 Stimmen
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!