{"id":250,"date":"2017-09-13T11:37:52","date_gmt":"2017-09-13T14:37:52","guid":{"rendered":"http:\/\/www.professores.uff.br\/diomarcesarlobao\/?page_id=250"},"modified":"2017-09-13T11:37:52","modified_gmt":"2017-09-13T14:37:52","slug":"readwriteplot_dio-matlab-script","status":"publish","type":"page","link":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/readwriteplot_dio-matlab-script\/","title":{"rendered":"ReadWritePlot_Dio Matlab script"},"content":{"rendered":"<pre>%========================================================================\r\n%  File:  ReadWritePlot.m\r\n%\r\n%  Read a data file and plot it with symbols\r\n%\r\n%  By Prof. Diomar Cesar Lobao\r\n%  UFF - Volta redonda RJ - Brazil\r\n%  February 23, 2007\r\n%------------------------------------------------------------------------\r\n%  readColData  reads data from a file containing data in columns\r\n%                that have text titles, and possibly other header text\r\n% \r\n%   Synopsis:\r\n%      [labels,x,y] = readColData(fname)\r\n%      [labels,x,y] = readColData(fname,ncols)\r\n%      [labels,x,y] = readColData(fname,ncols,nhead)\r\n%      [labels,x,y] = readColData(fname,ncols,nhead,nlrows)\r\n%    \r\n%   Input:\r\n%      fname  = name of the file containing the data (required)\r\n%      ncols  = number of columns in the data file.  Default = 2.  A value\r\n%               of ncols is required only if nlrows is also specified.\r\n%      nhead  = number of lines of header information at the very top of\r\n%               the file.  Header text is read and discarded.  Default = 0.\r\n%               A value of nhead is required only if nlrows is also specified.\r\n%      nlrows = number of rows of labels.  Default = 1\r\n% \r\n%   Output:\r\n%      labels  =  matrix of labels.  Each row of lables is a different\r\n%                 label from the columns of data.  The number of columns\r\n%                 in the labels matrix equals the length of the longest\r\n%                 column heading in the data file.  More than one row of\r\n%                 labels is allowed.  In this case the second row of column\r\n%                 headings begins in row ncol+1 of labels.  The third row\r\n%                 column headings begins in row 2*ncol+1 of labels, etc.\r\n% \r\n%           NOTE:  Individual column headings must not contain blanks\r\n% \r\n%      value_x = column vector of x values\r\n%      value_y = matrix of y values.  y has length(x) rows and ncols columns\r\n% \r\n%========================================================================\r\n%  open file for input, including error handling\r\nif input('\\nWould you like to read the information from a file?(y,n)\\n?','s')=='y'\r\n\t\tfilename=input('Enter a file name.\\n?','s');\r\n\t\tfilename=strcat(filename,'.dat');\r\n\t\tfid=fopen(filename,'r');\r\n          if fid &lt; 0\r\n             error(['Could not open ',filename,' for input']);\r\n          end\r\n   \treadfromfile=1;\r\n   end\r\n\r\n%  read labels and x-y data\r\n[labels,value_x,value_y] = readColData(filename,2,0);\r\n\r\nplot(value_x,value_y(:,1),'-ko');\r\n\r\nxlabel('Value of x');              %  add axis labels and plot title\r\nylabel('Value of y');\r\ntitle('Your first graphic in Matlab...');\r\n%\r\n% End script of Read and Plot<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>%======================================================================== % File: ReadWritePlot.m % % Read a data file and plot it with symbols % % By Prof. Diomar Cesar Lobao % UFF &#8211; Volta redonda RJ &#8211; Brazil % February 23, 2007 %&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212; % readColData reads data from a file containing data in columns % that have text titles, and possibly other header [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[],"tags":[],"class_list":["post-250","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/250","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/comments?post=250"}],"version-history":[{"count":1,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/250\/revisions"}],"predecessor-version":[{"id":251,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/pages\/250\/revisions\/251"}],"wp:attachment":[{"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/media?parent=250"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/categories?post=250"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.professores.uff.br\/diomarcesarlobao\/wp-json\/wp\/v2\/tags?post=250"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}