Understanding the code dlmwrite

조회 수: 6 (최근 30일)
Akmal Rahmat
Akmal Rahmat 2014년 11월 13일
댓글: Akmal Rahmat 2014년 11월 15일
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)

채택된 답변

Geoff Hayes
Geoff Hayes 2014년 11월 13일
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.
  댓글 수: 1
Akmal Rahmat
Akmal Rahmat 2014년 11월 15일
Thank you for your explanation sir.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by