Reputation: 987
I have a pretty simple octave script and I'm just trying to plot a few values but I'm getting the error:
warning: gl-render: data values greater than float capacity. (1) Scale data, or (2) Use gnuplot
The script is:
a = 0.2;
z = 160;
L = 8;
w = 31.12;
x = 0;
g = 9.81;
k = 0.785;
rho = 1025;
for t = 0:10
eta_0 = -(1/g)*exp(0)*cos(k*x-w*t);
u_x = a*w*exp(k*z)*cos(k*x-w*t);
w_x = a*w*exp(k*z)*sin(k*x-w*t);
p_d = -rho*a*g*exp(k*z)*cos(k*x-w*t);
endfor
plot(t,eta_0); hold on
plot(t,u_x); hold on
plot(t, w_x); hold on
plot(t,p_d);
I can't find anything useful about this error after searching online and am new to using octave and gnuplot so not sure exactly how to use gnuplot instead. I am using Ubuntu 12.04. Any advice or help would be really appreciated.
Thanks!
Upvotes: 3
Views: 14380
Reputation: 13886
You probably want your loop to be as follows, otherwise, you'll only get a single data point, not a curve:
for t = 0:10
eta_0(t) = -(1/g)*exp(0)*cos(k*x-w*t);
u_x(t) = a*w*exp(k*z)*cos(k*x-w*t);
w_x(t) = a*w*exp(k*z)*sin(k*x-w*t);
p_d(t) = -rho*a*g*exp(k*z)*cos(k*x-w*t);
endfor
or even better (without the for loop, using vectorised operations):
t = 0:10;
eta_0 = -(1/g)*exp(0)*cos(k*x-w*t);
u_x = a*w*exp(k*z)*cos(k*x-w*t);
w_x = a*w*exp(k*z)*sin(k*x-w*t);
p_d = -rho*a*g*exp(k*z)*cos(k*x-w*t);
The values you are trying to plot are very large (~7e57), which is probably the source of the error. Try adding graphics_toolkit('gnuplot')
at the beginning of your code to use the gnuplot
graphics toolkit and see if it works better. I tried it in octave 3.8 and it works fine, giving me the following plot:
Upvotes: 1