Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Please format this code..?

Asked by Lalit Patil on 6 Dec 2012

function [] = myFunction(imageNumber)

I = imread(sprintf('%d.png',imageNumber));

threshold = graythresh(I);

originalImage = im2bw(I, threshold);

i = bwareaopen(originalImage,350);

m = max(max(i));

[r c] = find(i == m);

fid = fopen(sprintf('Image%d_lalit1.txt',imageNumber),'wt');

for j=1:length(r),

    fprintf(fid,'%f %f\n',r(j),c(j));

end

fclose(fid);

data = textread(sprintf('Image%d_lalit1.txt',imageNumber));

r = unique(data);

for i=r',

    c = data(data(:,2)==i,1);
    z(i,1) = mean([min(c) max(c)]);

end

fid = fopen(sprintf('patil%d.txt',imageNumber),'wt');

for j=1:length(z),

    fprintf(fid,'%f %f\n',j,z(j));

end

data = textread(sprintf('patil%d.txt',imageNumber));

data(data(:,2) > 279, :) = [];

.......................................................................................................................................................

and now i want to save this files, so, what will be the last line of this function..?

I my self, first asked the question, then i was unclear about this so, i deleted it, now i again stucked so, i asked this as new question..

5 Comments

José-Luis on 6 Dec 2012

Please format your post properly. It will make it easier for people to help you.

Jan Simon on 6 Dec 2012

Who has changed the title of this question to "please format this code...?"?

Lalit Patil on 7 Dec 2012

In this code at last two lines it reads data from patil%d and processing

data(data(:,2) > 279, :) = [];

this it updates patil%d only with second column, but i want to create a new file which saves this second column operation and its corresponding first column element..

But, actually i changed the way now, i didn't want to add this two lines in this code, instead i taken it as another function..

So, it solved..

Lalit Patil

Products

No products are associated with this question.

1 Answer

Answer by Muruganandham Subramanian on 6 Dec 2012
Edited by Muruganandham Subramanian on 6 Dec 2012

Use 'diary' command

0 Comments

Muruganandham Subramanian

Contact us