I am getting Warning: Ignoring extra legend entries
Show older comments
% T represents Temperature in Kelvin,K
% mu represnt Viscosity
%downloading the ascii data file
Data = importdata('viscosity_data.dat');
T= Data(1,:);
mu= Data(2,:);
% to return the no.of elements n1 & n2 in arrays of T & mu
n1=numel(T);
n2=numel(mu);
i=0; % dependent variable, changing w/change in temp.
if n1==n2
K=input('Enter Temperature,K at which to estimate Viscosity: ');
if K>=T(1) && K<=T(n1)
% for loop
for m=1:n1
if T(m)==K;
i=mu(m);
end %end if 6
if(i==0)
if (K<=T(m) && K>=T(m-1))
% applying the variable into linear interpolation equation
i=(mu(m)-mu(m-1))/(T(m)-T(m-1))*(K-T(m)+mu(m));
end %end if 5
end %end if 4
end %end for loop 3
else
fprintf('Temperature not within Range, Try again.');
end %end if 2
else
fprintf('Invalid Data. Rerun program');
end %end if 1
plot(T,mu,'-o');
grid on
legend('T','mu');
xlabel('Temperature, T/K');
ylabel('Viscosity (*10^-5 kg/ms');
title('Viscosity versus Temperature');
Accepted Answer
More Answers (0)
Categories
Find more on Legend 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!