Info

This question is closed. Reopen it to edit or answer.

Reading in string variable and keeping the integrity of the dataset

2 views (last 30 days)
I have a set of data that has stringnames and empty cells (which could be set to zeros. I am able to read them in thanks to some which was provided to me awhile ago by the group. However, when I insert the str2num function, I then lose the "gaps" between the data that are important for me. I am looking at a set of values that are gait data, the numbers identify the pressure and placement during a step, the empty cells (blanks '-') indicate the foot being off of the pressure plate. The code I have removes these blanks and provides a continuous column of values but, I cannot tell when one footstep begins and ends (unless manually inspecting values). It would help to be able to run analyses on each individual footstep as well as identify the number of steps in each period. I cannot for the life of me figure out the code to preserve the integrity of the data and allowing it to be read in. I have attached a small section of the data and the code I have used. Any help would be appreciated...... thanks so much in advance.
Force,N X,mm Y,mm
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
110.45 34.76 33.14
313.42 34.76 33.14
363.98 34.76 33.14
426.73 34.87 35.11
436.06 35.32 36.92
441.08 36.12 40.39
449.68 37.25 43.26
498.81 38.68 47.68
534.67 40.29 51.55
553.32 41.93 56.22
593.12 43.49 59.72
619.66 44.81 63.53
640.46 45.79 65.65
661.97 46.43 68.02
693.17 46.79 68.98
705 47 70.6
707.52 47.23 71.55
703.57 47.48 73.58
688.15 47.91 75.3
664.84 48.46 78.71
648.35 49.25 83.64
626.83 50.07 88.29
594.56 50.95 94.51
572.68 51.69 99.98
555.47 52.24 107.15
543.28 52.76 114.81
520.69 52.86 124.39
483.39 52.48 133.15
477.29 51.6 139.8
482.67 50.46 146.22
504.91 49.36 151.04
536.1 48.29 156.59
550.09 47.45 161.05
561.21 46.64 166.4
565.51 46.05 170.45
582.36 45.36 174.85
602.45 44.62 178.02
612.13 44.27 181.49
580.57 44.07 183.42
547.94 43.82 184.02
597.43 43.68 184.77
702.14 43.7 183.84
730.47 43.18 182.88
686.72 42.45 182.93
756.64 41.48 184.07
781.03 40.48 184.53
769.55 39.45 185.78
758.79 38.36 186.05
742.3 37.36 185.38
731.9 36.42 185.29
728.31 35.52 184.45
678.83 34.61 184.78
649.06 33.72 184.39
596.71 32.99 185
544.71 32.44 184.73
480.88 31.9 185.85
372.94 30.3 188.31
260.34 27.53 194.24
141.29 25.04 199.94
91.08 22.89 206.96
54.51 21.46 212.84
30.48 21.46 212.84
11.48 21.46 212.84
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
8.96 24.57 30.29
240.98 24.57 30.29
340.67 24.57 30.29
423.5 24.67 31.19
450.04 25.16 33.62
460.8 26.08 35.94
469.41 27.45 39.92
486.98 29.2 43.54
532.88 31.15 48.49
542.2 33.18 52.62
561.92 35.06 57.23
573.76 36.67 60.55
594.2 37.88 63.99
612.85 38.74 65.97
632.21 39.32 68.64
657.67 39.79 70.2
671.66 40.29 72.98
679.19 40.83 75.15
677.39 41.49 78.87
658.03 42.1 82.18
642.61 42.71 87.04
623.24 43.22 91.52
603.52 43.53 97.05
582.01 43.63 101.62
569.45 43.41 107.44
565.87 43 113.04
561.21 42.54 121.17
557.26 42.01 128.96
535.75 41.46 137.19
538.62 40.77 143.42
556.19 40.29 149.59
581.65 39.99 154.18
598.5 39.86 159.56
601.37 39.85 163.6
607.11 39.76 168.2
604.96 39.58 172.6
623.96 39.03 175.73
644.76 38.51 179.39
630.06 38.23 181.62
573.4 37.99 184.17
563 37.61 185.48
641.17 37.59 185.1
748.04 37.38 185.04
708.95 36.8 184.86
697.83 36 185.69
766.68 35.16 185.68
758.44 34.25 186.57
751.98 33.46 186.5
726.16 32.63 187.32
726.88 31.85 187.12
717.91 31.11 187.76
686.36 30.36 187.7
647.99 29.74 188.63
595.63 29.21 188.62
545.79 28.73 189.54
478.37 28.24 189.61
365.77 26.94 192.5
265.72 24.12 197.28
146.67 21.55 203.82
83.19 19.3 209.91
49.49 17.84 216.68
27.25 17.84 216.68
10.4 17.84 216.68
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
33.71 39.05 36.2
319.51 39.05 36.2
359.67 39.05 36.2
433.55 39.31 37.35
433.55 40.08 40.67
434.98 41.33 44.73
444.66 42.73 50.27
490.56 44.12 55.3
527.86 45.36 61.06
538.97 46.49 66.89
572.32 47.34 71.76
597.78 47.85 77.6
616.43 47.94 81.89
664.84 47.68 86.1
707.87 47.12 91.07
736.2 46.41 95.15
770.27 45.71 100.23
758.08 45.11 104.98
737.28 44.77 111.05
711.1 44.68 116.84
680.62 44.81 124.5
651.93 45.06 131.48
625.04 45.36 139.77
592.76 45.65 146.94
578.42 45.84 155.03
553.68 46.02 162.15
540.77 46.17 169.77
538.26 46.26 175.78
520.33 46.32 181.83
526.06 46.29 187.71
527.86 46.26 191.78
550.09 46.11 195.47
563 45.89 196.93
578.06 45.62 198.43
590.61 45.47 200
611.41 45.56 200.2
630.42 45.75 201.01
645.48 45.94 200.55
666.99 45.8 201.07
683.85 45.29 201.24
675.24 45.11 202.72
629.34 45.08 203.26
584.16 45.08 202.98
623.6 45.28 203.26
737.28 45.62 202.11
749.11 45.36 201.17
691.02 44.77 201.31
763.1 44.02 200.89
765.61 43.19 201.5
752.7 42.43 201.21
729.03 41.72 201.85
698.19 41.18 201.61
664.48 40.82 202.14
630.06 40.6 201.66
563 40.52 202.01
485.18 40.38 201.48
396.25 39.58 202.94
299.07 36.46 207.29
183.6 32.59 214.13
92.16 28.83 220.83
69.21 25.65 228.42
38.37 23.45 234.54
20.44 23.45 234.54
7.17 23.45 234.54
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
0 - -
The code is:
fid=fopen('filename');
c=textscan(fid,'%f%s%s','headerlines',2);
fclose(fid);
p=c{1};
indx=p>0;
cx=c{2};
x=str2num(char(cx(indx)));
cy=c{3};
y=str2num(char(cy(indx)));
Thanks again,
ktatc

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!