Plot user-defined functions

From: <anna_at_nyahnyahspammersnyahnyah>
Date: Sun Sep 29 2013 - 06:47:09 MDT

I like to creat my own function f(x)= 9.44* 0.0065 *x and I like to plot this function.
I can creat the function and get values for different x. But I can draw this function. Can you pleas help me.
Here is my code and my error message:
Thanks.
;************************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;************************************************************
begin

undef("temp") ;Erstellen von f(x)
function temp(x)
begin
 fx = 9.44-0.0065 * x ; Definition von f(x)
 return (fx)
end
answer = temp(10)
print(answer) ; Ausgeben der Temperatur

;***********************************Plot*************************************************************************
 wks_type = "pdf"
 wks = gsn_open_wks(wks_type,"Temperaturprofil1")
 res = True
 res@gsnDraw = False ; don't draw
 res@gsnFrame = False
 ;res@trYReverse = True ;reverser Y-axis
 ;res@trXMinF = 200
 ;res@trXMaxF = 310
 res@tiXAxisString = "Temperatur / K"
 res@tiYAxisString = "Druck / hPa"
 res@xyLineColors =(/"red"/)
 do x=0,4
 plot1 = gsn_csm_xy(wks, temp(x),x,res)
 end do
 draw(plot1)
 frame(wks)

end
fatal:CheckArray:Each vector in the caXArray array must have at least 2 elements
fatal:CoordArraysInitialize:caXArray resource is invalid
fatal:Unable to initialize layer-Can't Create
fatal:Unable to access object with id:-4
fatal:Unable to access object with id:-4
warning:Unable to add DataItem "(null)" to DataList "xyCoordData"
fatal:CompileDataList:DataList has no valid members
fatal:Unable to access object with id:-4
warning:Unable to add DataItem "(null)" to DataList "xyCoordData"
fatal:CompileDataList:DataList has no valid members
fatal:Argument type mismatch on argument (0) of (attsetvalues_check) can not coerce
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 11955 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 5016 in file $NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 40 in file Standardtemp.ncl

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Sep 29 06:47:21 2013

This archive was generated by hypermail 2.1.8 : Tue Oct 01 2013 - 14:41:43 MDT