clc clear all close all % ABSTRACT disp('ABSTRACT') disp(' Cushed Can Von-Mises Stress') disp(' ') % INPUTS disp('INPUTS') filen='C:\Documents and Settings\djmille3\Desktop\max_von_mises_sodacan.txt'; fh=fopen(filen,'r'); fprintf(' The file location is:\n %s\n\n',filen) % CODE/OUTPUTS % reading the input file a=' '; % To get things started i=0; % counter for while-end loop while ischar(a)==true a=fgets(fh); % if there's a character, read the line if ischar(a)==true b=sscanf(a,'%f'); % what is on the line? i=i+1; stress(i)=b; % make storage stress vector end end % finding the max stress mstress=stress(1); n=length(stress); % find number of elements for i=2:1:n if stress(i)>mstress mstress=stress(i); end end disp('OUTPUTS') fprintf(' The maximun stress is %g Pa\n',mstress)