@@ -226,6 +226,206 @@ json2data =
226226
227227 complex_sparse : [10x10 double ]
228228
229+ >> >>
230+ % =================================================
231+ >> % an all-zero sparse matrix
232+ >> % =================================================
233+
234+ >> >> >>
235+ ans =
236+
237+ {
238+ " all_zero_sparse" : {
239+ " _ArrayType_" : " double" ,
240+ " _ArraySize_" : [2 ,3 ],
241+ " _ArrayIsSparse_" : 1 ,
242+ " _ArrayData_" : null
243+ }
244+ }
245+
246+
247+ >>
248+ json2data =
249+
250+ all_zero_sparse : [2x3 double ]
251+
252+ >> >>
253+ % =================================================
254+ >> % an empty sparse matrix
255+ >> % =================================================
256+
257+ >> >> >>
258+ ans =
259+
260+ {
261+ " empty_sparse" : {
262+ " _ArrayType_" : " double" ,
263+ " _ArraySize_" : [0 ,0 ],
264+ " _ArrayIsSparse_" : 1 ,
265+ " _ArrayData_" : null
266+ }
267+ }
268+
269+
270+ >>
271+ json2data =
272+
273+ empty_sparse : []
274+
275+ >> >>
276+ % =================================================
277+ >> % an empty 0-by-0 real matrix
278+ >> % =================================================
279+
280+ >> >> >>
281+ ans =
282+
283+ {
284+ " empty_0by0_real" : {
285+ " _ArrayType_" : " double" ,
286+ " _ArraySize_" : [0 ,0 ],
287+ " _ArrayData_" : null
288+ }
289+ }
290+
291+
292+ >>
293+ json2data =
294+
295+ empty_0by0_real : []
296+
297+ >> >>
298+ % =================================================
299+ >> % an empty 0-by-3 real matrix
300+ >> % =================================================
301+
302+ >> >> >>
303+ ans =
304+
305+ {
306+ " empty_0by3_real" : {
307+ " _ArrayType_" : " double" ,
308+ " _ArraySize_" : [0 ,3 ],
309+ " _ArrayData_" : null
310+ }
311+ }
312+
313+
314+ >>
315+ json2data =
316+
317+ empty_0by3_real : [0x3 double ]
318+
319+ >> >>
320+ % =================================================
321+ >> % a sparse real column vector
322+ >> % =================================================
323+
324+ >> >> >>
325+ ans =
326+
327+ {
328+ " sparse_column_vector" : {
329+ " _ArrayType_" : " double" ,
330+ " _ArraySize_" : [5 ,1 ],
331+ " _ArrayIsSparse_" : 1 ,
332+ " _ArrayData_" : [
333+ [2 ,3 ],
334+ [4 ,1 ],
335+ [5 ,4 ]
336+ ]
337+ }
338+ }
339+
340+
341+ >>
342+ json2data =
343+
344+ sparse_column_vector : [5x1 double ]
345+
346+ >> >>
347+ % =================================================
348+ >> % a sparse complex column vector
349+ >> % =================================================
350+
351+ >> >> >>
352+ ans =
353+
354+ {
355+ " complex_sparse_column_vector" : {
356+ " _ArrayType_" : " double" ,
357+ " _ArraySize_" : [5 ,1 ],
358+ " _ArrayIsComplex_" : 1 ,
359+ " _ArrayIsSparse_" : 1 ,
360+ " _ArrayData_" : [
361+ [2 ,3 ,-3 ],
362+ [4 ,1 ,-1 ],
363+ [5 ,4 ,-4 ]
364+ ]
365+ }
366+ }
367+
368+
369+ >>
370+ json2data =
371+
372+ complex_sparse_column_vector : [5x1 double ]
373+
374+ >> >>
375+ % =================================================
376+ >> % a sparse real row vector
377+ >> % =================================================
378+
379+ >> >> >>
380+ ans =
381+
382+ {
383+ " sparse_row_vector" : {
384+ " _ArrayType_" : " double" ,
385+ " _ArraySize_" : [1 ,5 ],
386+ " _ArrayIsSparse_" : 1 ,
387+ " _ArrayData_" : [
388+ [2 ,3 ],
389+ [4 ,1 ],
390+ [5 ,4 ]
391+ ]
392+ }
393+ }
394+
395+
396+ >>
397+ json2data =
398+
399+ sparse_row_vector : [0 3 0 1 4 ]
400+
401+ >> >>
402+ % =================================================
403+ >> % a sparse complex row vector
404+ >> % =================================================
405+
406+ >> >> >>
407+ ans =
408+
409+ {
410+ " complex_sparse_row_vector" : {
411+ " _ArrayType_" : " double" ,
412+ " _ArraySize_" : [1 ,5 ],
413+ " _ArrayIsComplex_" : 1 ,
414+ " _ArrayIsSparse_" : 1 ,
415+ " _ArrayData_" : [
416+ [2 ,3 ,-3 ],
417+ [4 ,1 ,-1 ],
418+ [5 ,4 ,-4 ]
419+ ]
420+ }
421+ }
422+
423+
424+ >>
425+ json2data =
426+
427+ complex_sparse_row_vector : [1x5 double ]
428+
229429>> >>
230430% =================================================
231431>> % a structure
@@ -295,7 +495,7 @@ ans =
295495>>
296496json2data =
297497
298- Supreme_0x20_Commander : [1x3 struct ]
498+ Supreme_0x20_Commander : {[1x1 struct ] [1x1 struct ] [1x1 struct ]}
299499
300500>> >>
301501% =================================================
@@ -314,36 +514,38 @@ ans =
314514
315515{
316516 " debian" : [
317- {
318- " buzz" : 1.10 ,
319- " rex" : 1.20 ,
320- " bo" : 1.30 ,
321- " hamm" : 2.00 ,
322- " slink" : 2.10 ,
323- " potato" : 2.20 ,
324- " woody" : 3.00 ,
325- " sarge" : 3.10 ,
326- " etch" : 4.00 ,
327- " lenny" : 5.00 ,
328- " squeeze" : 6.00 ,
329- " wheezy" : 7.00
330- },
331- {
332- " Ubuntu" : [
333- " Kubuntu" ,
334- " Xubuntu" ,
335- " Lubuntu"
336- ]
337- },
338- [10.04 ,10.10 ,11.04 ,11.10 ]
517+ [
518+ {
519+ " buzz" : 1.10 ,
520+ " rex" : 1.20 ,
521+ " bo" : 1.30 ,
522+ " hamm" : 2.00 ,
523+ " slink" : 2.10 ,
524+ " potato" : 2.20 ,
525+ " woody" : 3.00 ,
526+ " sarge" : 3.10 ,
527+ " etch" : 4.00 ,
528+ " lenny" : 5.00 ,
529+ " squeeze" : 6.00 ,
530+ " wheezy" : 7.00
531+ },
532+ {
533+ " Ubuntu" : [
534+ " Kubuntu" ,
535+ " Xubuntu" ,
536+ " Lubuntu"
537+ ]
538+ },
539+ [10.04 ,10.10 ,11.04 ,11.10 ]
540+ ]
339541 ]
340542}
341543
342544
343545>>
344546json2data =
345547
346- debian : {[1x1 struct ] [1x1 struct ] [ 10.0400 10.1000 11.0400 11.1000 ] }
548+ debian : {{1x3 cell } }
347549
348550>> >>
349551% =================================================
@@ -358,4 +560,103 @@ json2data =
358560 x0x3A_Field_0x3A_ : 3
359561 x0xE9A1B9__0xE79BAE_ : ' 绝密'
360562
563+ >> >>
564+ % =================================================
565+ >> % a 2D cell array
566+ >> % =================================================
567+
568+ >> >> >>
569+ ans =
570+
571+ {
572+ " data2json" : [
573+ [
574+ [
575+ [1 ],
576+ [
577+ [2 ],
578+ [3 ]
579+ ]
580+ ],
581+ [7 ]
582+ ],
583+ [
584+ [
585+ [4 ],
586+ [5 ]
587+ ],
588+ [
589+ [8 ],
590+ [9 ]
591+ ]
592+ ],
593+ [
594+ [6 ],
595+ [10 ]
596+ ]
597+ ]
598+ }
599+
600+
601+ >>
602+ json2data =
603+
604+ data2json : [10x1 double ]
605+
606+ >> >>
607+ % =================================================
608+ >> % a 2D struct array
609+ >> % =================================================
610+
611+ >> >>
612+ data2json =
613+
614+ 2x3 struct array with fields:
615+ idx
616+ data
617+
618+ >> >>
619+ ans =
620+
621+ {
622+ " data2json" : [
623+ [
624+ {
625+ " idx" : 1 ,
626+ " data" : " structs"
627+ },
628+ {
629+ " idx" : 2 ,
630+ " data" : " structs"
631+ }
632+ ],
633+ [
634+ {
635+ " idx" : 3 ,
636+ " data" : " structs"
637+ },
638+ {
639+ " idx" : 4 ,
640+ " data" : " structs"
641+ }
642+ ],
643+ [
644+ {
645+ " idx" : 5 ,
646+ " data" : " structs"
647+ },
648+ {
649+ " idx" : 6 ,
650+ " data" : " structs"
651+ }
652+ ]
653+ ]
654+ }
655+
656+
657+ >>
658+ json2data =
659+
660+ data2json : {{1x2 cell } {1x2 cell } {1x2 cell }}
661+
361662>> >> >> >>
0 commit comments