z = str2num(all{n}(1:79)); is a piece of code that I'm using. all{} is 698x1 cell array. I'm trying to figure out if instead of using(1:79) if there as way of saying I need everything in the cell. Something like(:) to say I want all{}(:)?

2 views (last 30 days)
c1=0;
n1=204;
w=0;
while c1<75
i = str2num(all{n1}(1:77));
w = horzcat(w,i);
n1=n1+1;
c1=c1+1;
end
Name Size Bytes Class Attributes
DUI2 1x1 8 double
all 698x1 186438 cell
ans 1x1 8 double
c 1x1 8 double
c1 1x1 8 double
fileID 1x1 8 double
filename662 1x15 30 char
i 1x5 40 double
n 1x1 8 double
n1 1x1 8 double
noDUInd 1x4 8 char
noDatRec 1x3 6 char
noIndex 1x10 20 char
noPointer 1x9 18 char
noValue 1x12 24 char
numCol 1x3 6 char
numRow 1x3 6 char
this_line 0x0 0 char
v 1x657 5256 double
w 1x286 2288 double
z 1x16 128 double
This is 4 through 13 of the cell just to give you an idea of what stored inside
' 1 4 8 11 14 17 20 23 30 33 38 41 44 47 50 56'
' 59 62 65 68 71 74 77 80 83 89 92 95 98 101 104 108'
' 111 114 122 124 127 130 133 136 139 142 144 147 152 156 159 162'
' 165 168 171 174 177 179 182 185 190 193 199 202 204 207 210 213'
' 215 218 221 224 227 232 235 238 241 244 249 256 259 261 264 267'
' 270 273 276 279 282 285 288 290 293 296 299 301 303 306 309 312'
' 315 318 322 324 326 329 332 334 337 340 343 347 353 356 359 362'
' 365 371 374 377 380 383 387 391 394 397 403 406 411 414 417 419'
' 422 425 428 431 434 437 440 444 447 450 453 456 459 462 469 474'
' 477 479 485 488 493 496 499 502 505 507 510 513 520 523 526 529'
  1 Comment
Stephen23
Stephen23 on 26 Sep 2017
Edited: Stephen23 on 26 Sep 2017
Where did the data come from? If these are lines from a file then you should simply import them correctly to start with, rather than inefficiently importing them as strings and then writing some hack-code to convert the strings to numeric. That would be complex, inefficient, and a total waste of your time.
Fix the problem at the source!
Please edit your question and click the paperclip button to upload your data for us to try out.

Sign in to comment.

Answers (1)

Stephen23
Stephen23 on 26 Sep 2017
Edited: Stephen23 on 26 Sep 2017
Assuming that your data are stored in a text file of some sort, you should fix the problem at the source by simple importing your data correctly, e.g.:
>> M = dlmread('temp0.txt')
M =
1 4 8 11 14 17 20 23 30 33 38 41 44 47 50 56
59 62 65 68 71 74 77 80 83 89 92 95 98 101 104 108
111 114 122 124 127 130 133 136 139 142 144 147 152 156 159 162
165 168 171 174 177 179 182 185 190 193 199 202 204 207 210 213
215 218 221 224 227 232 235 238 241 244 249 256 259 261 264 267
270 273 276 279 282 285 288 290 293 296 299 301 303 306 309 312
315 318 322 324 326 329 332 334 337 340 343 347 353 356 359 362
365 371 374 377 380 383 387 391 394 397 403 406 411 414 417 419
422 425 428 431 434 437 440 444 447 450 453 456 459 462 469 474
477 479 485 488 493 496 499 502 505 507 510 513 520 523 526 529
The file I used is attached to this answer.

Community Treasure Hunt

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

Start Hunting!