Storing values using csapi (spline functin)
이전 댓글 표시
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.
답변 (2개)
Sean de Wolski
2012년 2월 24일
0 개 추천
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
Mauricio Marulanda
2012년 2월 24일
Sean de Wolski
2012년 2월 24일
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
2012년 2월 24일
Sean de Wolski
2012년 2월 24일
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
2012년 2월 24일
save those four lines of code as csapiCell somewhere on the MATLAB path.
Mauricio Marulanda
2012년 2월 24일
Mauricio Marulanda
2012년 2월 24일
Sean de Wolski
2012년 2월 24일
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
2012년 2월 24일
Sean de Wolski
2012년 2월 24일
If called correctly it will take a cell array:
doc csapi
Mauricio Marulanda
2012년 2월 24일
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!