Change or save data .txt

조회 수: 1 (최근 30일)
Akmal Rahmat
Akmal Rahmat 2014년 11월 22일
댓글: Image Analyst 2014년 11월 23일
a = dlmread('test4.txt');
b = dlmread('test5.txt');
if (a-b)>125
c = (a-b)>125;
c = 0;
c = dlmmwrite('test4.txt','delimiter');
c = dlmwrite('test5.txt','delimiter');
end
hello all. i need help.here is my code. how do i change the data in my .txt file ? when a-b meet my condition i want to change it in both .txt file. i keep getting error. please help me. thank you
  댓글 수: 5
Akmal Rahmat
Akmal Rahmat 2014년 11월 22일
here is the text file. i want to change both file value when it meet the condition where the a-b value more than 125 then the number in the txt file will change to zero.
Guillaume
Guillaume 2014년 11월 22일
편집: Guillaume 2014년 11월 22일
If you'd answered the question I asked we would be much closer to helping you. So, once again, if
a = [255 255 0 124 126]
b = [255 0 255 126 124]
What final a and b do you expect? Bearing in mind that:
(a-b) == [0 255 -255 -2 2]

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

답변 (1개)

Image Analyst
Image Analyst 2014년 11월 22일
편집: Image Analyst 2014년 11월 22일
Try this (untested because you didn't attach your text files):
a = dlmread('test4.txt');
b = dlmread('test5.txt');
c =(a-b)>125; % Logical array
a(c) = 0; % Replace elements in a with 0;
b(c) = 0; % Replace elements in b with 0;
% Write updated a and b back out.
dlmwrite('test4.txt', a);
dlmwrite('test5.txt', b);
  댓글 수: 10
Akmal Rahmat
Akmal Rahmat 2014년 11월 22일
a and b are different sizes ? i just resize a to 100x100 and rename it as b ? is my code right?
originally my task is to compare two image that been convert to text file. i attach the image that i will use. all i want is to read each value in both text file then make comparison of it and show the percentage of different between two text file.
a = imread('img2.jpg');
b = imresize(a,[100,100])
dlmwrite('test4.txt', b, 'delimiter', ',');
d = dlmread('test4.txt');
e = imread('img1.jpg');
f = imresize(e,[100,100])
dlmwrite('test5.txt', f, 'delimiter', ',');
g = dlmread('test5.txt');
here is my way to convert the image to text file. the problem is how to calculate the different between two text file. sir do you have any idea how i should do it. i am stuck here.
Image Analyst
Image Analyst 2014년 11월 23일
Use my code in the comment, but have C be this:
c = a ~= b; % Logical array
This will calculate where a and b are different, like you asked for.

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

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by