Clear Filters
Clear Filters

Convert values in text file into matrix

8 views (last 30 days)
How to convert values in a text file to 80*64 matrix? Text file is attched.

Accepted Answer

Voss
Voss on 18 Mar 2022
This file contains 5120 numbers on a single line, so the matrix is of size 1-by-5120:
A = readmatrix('textT.txt','Delimiter',' ')
A = 1×5120
118 218 201 124 173 156 178 196 168 187 188 185 186 184 187 188 185 185 189 186 188 188 191 188 189 185 187 186 187 189
  2 Comments
Neha Tom Merin
Neha Tom Merin on 18 Mar 2022
I would like to convert it to an 80*64 matrix
Voss
Voss on 18 Mar 2022
A = readmatrix('textT.txt','Delimiter',' ')
A = 1×5120
118 218 201 124 173 156 178 196 168 187 188 185 186 184 187 188 185 185 189 186 188 188 191 188 189 185 187 186 187 189
A = reshape(A,80,64) % numbers in the file go down the first column of A first
A = 80×64
118 90 187 111 151 158 117 111 104 158 137 167 181 186 180 185 180 183 186 182 184 186 185 180 186 185 185 183 188 189 218 131 143 113 132 112 133 150 147 141 176 183 180 183 183 181 183 183 182 184 185 182 184 182 181 183 185 185 183 185 201 180 150 162 123 91 152 136 166 181 178 181 181 180 178 184 181 185 183 184 183 185 183 184 183 180 183 185 185 186 124 172 136 125 185 152 145 175 179 181 181 183 181 181 183 183 183 184 182 188 185 185 187 184 183 186 184 184 186 186 173 137 163 163 145 161 183 181 177 184 182 184 181 183 186 185 183 182 189 185 185 186 188 186 185 186 183 185 185 190 156 147 166 160 170 182 181 180 183 182 184 184 185 186 183 182 183 185 184 187 185 186 186 182 184 183 187 186 189 190 178 138 164 188 179 185 183 179 183 185 188 186 185 184 187 186 185 186 186 185 186 184 186 185 183 185 185 187 186 190 196 161 179 179 184 179 182 185 183 187 187 188 188 183 187 184 188 186 185 185 186 185 188 187 187 183 184 186 184 186 168 188 184 186 183 186 186 186 185 187 187 186 189 187 189 185 184 186 187 187 185 189 187 184 186 185 185 188 189 188 187 183 185 188 185 185 183 184 187 185 187 186 189 187 188 186 187 188 188 188 183 188 189 185 186 185 184 188 185 187
or perhaps
A = reshape(A,64,80).' % numbers in the file go across the first row of A first
A = 80×64
118 218 201 124 173 156 178 196 168 187 188 185 186 184 187 188 185 185 189 186 188 188 191 188 189 185 187 186 187 189 179 184 183 181 185 184 183 177 153 168 168 140 193 153 142 122 90 131 180 172 137 147 138 161 188 183 184 181 185 183 185 186 188 187 186 186 186 183 184 184 183 183 183 183 182 183 182 183 183 183 181 178 182 180 180 181 152 178 143 157 186 187 186 186 188 187 186 186 187 187 186 186 187 187 188 185 186 186 185 186 185 184 185 186 183 183 186 185 185 186 188 185 186 188 185 189 186 187 187 186 187 187 188 184 187 188 187 186 186 187 186 188 184 186 188 188 188 186 186 188 151 132 123 185 145 170 179 184 183 185 186 186 185 186 186 185 188 186 188 186 188 185 189 189 189 187 186 186 185 187 185 185 183 181 183 184 185 185 185 186 177 173 160 133 148 191 158 112 91 152 161 182 185 179 186 185 187 188 187 185 188 186 184 185 186 185 184 184 186 183 184 184 183 186 183 182 186 183 183 181 183 184 184 191 187 181 183 170 165 146 186 186 189 186 187 188 188 186 185 186 188 184 188 187 187 186 188 185 186 185 183 184 186 185 181 183 186 183 185 184 186 188 185 186 186 186 187 184 188 185 186 187 186 188 188 186 188 186 187 187 186 187 186 188 183 186 186 184 186 187

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!