How can I add a set of 500 datas to workspace and plot them?

1 view (last 30 days)
I have never used matlab. I have a set of 500 .ascii extensioned files. I open them in current folder. I click one of them and while holding it, I carry it to the workspace window. (this bring import wizard screen-I click next) I right click on the yellow colored ascii data on the workplace and plot it. then I need to save each of these plotted image in jpeg fomat. this needs to be done for each 500 items, I guess I need a script for this. but I dont know how to do it. Can someone help me please ?

Accepted Answer

dpb
dpb on 21 Aug 2014
Start with the FAQ at
I strongly recommend using the dir solution to process the files returned.
Something like the following should be a rough starting point...
d=dir('*.ascii'); % the directory list of files--salt wildcard/extension to suit
for i=1:length(d)
data=textread(d.name(i)); % read a file
plot(data(:,1),data(:,2)); % plot 2nd column vs first
[~,name]=fileparts(d.name(i)); % get the root name of the file
print -djpeg name % write to name[.jpg]
close 1 % close that figure
end
  1 Comment
Ferda
Ferda on 21 Aug 2014
thanks a million :) with couple of changes it worked for me. I did it like this:
d=dir('*.ascii');
for i=1:length(d)
data=textread(d(i).name,'%d'); % read a file
plot(data,'DisplayName','data','YDataSource','data');figure(gcf)
[~,name]=fileparts(d(i).name); % get the root name of the file
print ('-djpeg', name) % write to name[.jpg]
close 1 % close that figure
end
now I need to zoom in to the plotted images and save the zoomed file. how can I do this ?

Sign in to comment.

More Answers (0)

Categories

Find more on Visual Exploration in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!