From: address@hidden
To: address@hidden; address@hidden
Subject: RE: Formatted Output bug
Date: Sun, 16 Aug 2009 14:52:35 +0000
Date: Sun, 16 Aug 2009 01:27:42 -0700
From: address@hidden
Subject: Formatted Output bug
To: address@hidden
I was running this simple m-file. I think there is a bug in the printf statement. It simply cannot print two variables correctly. The second variable is always wrong. I can print them separately and it works. It has me baffled.
Ubuntu 9.04,
QtOctave version 0.7.4 Octave 3.0.1
mass=1500*[1 0 0 0;0 2 0 0;0 0 2 0;0 0 0 3]
stiff=800e3*[1 -1 0 0;-1 3 -2 0;0 -2 5 -3;0 0 -3 7]
mr=sqrtm(mass);
kt=inv(mr)*stiff*inv(mr);
[v,d]=eig(kt);
w=sqrt(d);
w=w*[1;1;1;1];
w=w./(2*pi)
T=1./w
printf("Natural Frequency = %.2f Hz \n" ,w)
printf("Period = %.2f Hz \n" ,T)
printf("Natural Frequency = %f Hz Period= %f \n", w ,T ) |
Find local businesses and services in your area with Yahoo!7 Local.
Get started..
On my ubuntu i get this
octave-3.0.1:14>
octave-3.0.1:14> printf("Natural Frequency = %.2f Hz \n" ,w)
Natural Frequency = 1.73 Hz
Natural Frequency = 3.85 Hz
Natural Frequency = 5.34 Hz
Natural Frequency = 7.26 Hz
octave-3.0.1:15>
octave-3.0.1:15> printf("Period = %.2f Hz \n" ,T)
Period = 0.58 Hz
Period = 0.26 Hz
Period = 0.19 Hz
Period = 0.14 Hz
octave-3.0.1:16>
octave-3.0.1:16> printf("Natural Frequency = %f Hz Period= %f \n", w ,T )
Natural Frequency = 1.727485 Hz Period= 3.854267
Natural Frequency = 5.338151 Hz Period= 7.261830
Natural Frequency = 0.578876 Hz Period= 0.259453
Natural Frequency = 0.187331 Hz Period= 0.137706
octave-3.0.1:17>
It is using all the w array first and then all the T array.
Doug Stewart
You
cold try
q=[w T]'
octave-3.0.1:16> printf("Natural Frequency = %f Hz Period= %f \n", q )
Natural Frequency = 1.727485 Hz Period= 0.578876
Natural Frequency = 3.854267 Hz Period= 0.259453
Natural Frequency = 5.338151 Hz Period= 0.187331
Natural Frequency = 7.261830 Hz Period= 0.137706
octave-3.0.1:24>