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