View Single Post
  #9  
Old 06-05-2010, 12:16 AM
ptjt255 ptjt255 is offline
Member
 
Join Date: Oct 2008
Posts: 24
I have managed to get pylab working, which is great news, thanks for all of your help.

I am now trying to convert my MatLab code, which is:

Quote:
dir = input('Path: ');
filename = input('Filename: ');
path = strcat(dir,filename);
eval(['data = textread(path,'''',''headerlines'',1);']);

A = []; B = [];

w = find(data(:,5) == 0);

b = find(data(w,9) == 4);
b1 = data(b,12);
c = find(data(w,9) == 5);
c1 = data(c,12);
d = find(data(w,9) == 6);
d1 = data(d,12);

A = [A; b1(1) c1(1) d1(1)]

carvscar = mean(A)* 2.23693629
ccnorm = 29.41;
ccnorm2 = 27.09;
ccnorm3 = 18.67;
ccnorm4 = 10.97;

x = find(data(:,5) == 2);

e = find(data(x,9) == 4);
e1 = data(e,12);
f = find(data(x,9) == 5);
f1 = data(f,12);
g = find(data(x,9) == 6);
g1 = data(g,12);

B = [B; e1(1) f1(1) g1(1)]

subplot(2,2,[1 3]); bar([carvscar, ccnorm, ccnorm2,ccnorm3,ccnorm4],'FaceColor',[0 0.5 0],'BarWidth',0.5)
subplot(2,2,[1 3]);title(strcat('Car vs Car'));ylabel('Speed Error (mph)','FontSize',11);ylim([0 70])
set(gca,'XTickLabel',{'Your Result';'6-7 year olds';'8-9 year olds';'10-11 year olds';'Adults'})

if data(x,7) == 2 % Truck
carvslorry = mean(B)*2.23693629
clnorm = 54.47;
clnorm2 = 38.81;
clnorm3 = 40.24;
clnorm4 = 15.25;
subplot(2,2,[2 4]); bar([carvscar, clnorm, clnorm2,clnorm3,clnorm4],'FaceColor',[0 0 0.5],'BarWidth',0.5); hold on;
subplot(2,2,[2 4]);ylabel('Speed Error (mph)','FontSize',11);title(strcat('Faster Car vs Slower Truck'));ylim([0 70]);
set(gca,'XTickLabel',{'Your Result';'6-7 year olds';'8-9 year olds';'10-11 year olds';'Adults'})
elseif data(x,7) == 1 % Motorbike
carvsbike = mean(B)*2.23693629
cbnorm = 10; % fictional speed difference, need to get data from Damian
subplot(2,2,[2 4]); bar([carvscar, cbnorm],'FaceColor',[0 0 0.5],'BarWidth',0.5); hold on;
subplot(2,2,[2 4]);ylabel('Speed Error (mph)','FontSize',11);title(strcat('Faster Car vs Slower Motorbike'));ylim([0 70]);
set(gca,'XTickLabel',{'Your Result';'Adults'})
end
I have figured out that to perform the open file procedure it's:

Quote:
dir = 'C:\\Data'
filename = input('Filename: ')
data = open(dir + filename + '.jnk', 'w')
But I can't figure out what the equivelent to:

Quote:
w = find(data(:,5) == 0);
is?

Many thanks!
Reply With Quote