Understanding the code dlmwrite
6 views (last 30 days)
Show older comments
Akmal Rahmat
on 13 Nov 2014
Commented: Akmal Rahmat
on 15 Nov 2014
Hello. can anyone help me to understand this code ?
- dlmwrite('test.txt', a, 'delimiter', ','); *
what is "a" and "delimiter" stand for in this code ?
one more is about reshape. below is the code.
c = reshape(b, x, y/3, 3);
i try to change "y/3" to "y/2" the result doesnt show up.
this is the full code. and sorry i really new in matlab. doesnt understand much the code.
a = imread('img2.jpg');
dlmwrite('test.txt', a, 'delimiter', ',');
b = dlmread('test.txt');
[x,y] = size(b);
c = reshape(b, x, y/3, 3);
image(c/255)
0 Comments
Accepted Answer
Geoff Hayes
on 13 Nov 2014
Akmal - see the link dlmwrite for details on this function. The a is the numeric data to write to file (in your case, the image data) and the delimiter is the option that indicates use a comma to separate array elements (since the string ',' follows this option).
See reshape for information on this function which should explain why you may be observing an error. When you reshape an array/matrix, in this case b, the product of the new shape dimensions, x*y/3*3, must be identical to the number of elements of b. By changing the second input to y/2, that condition may no longer be valid.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!