From: Etienne G. <et...@is...> - 2002-09-11 07:32:12
|
Hello On Tue, Sep 10, 2002 at 06:34:19PM -0400, Paul Kienzle wrote: # Etienne, # # I would model this on fplot, which does this for functions of one variable. E.g., # # fmesh('fn') - plots the bivariate function or expression. It is a function # if it is a single identifier otherwise it is an expression. I prefer having the building of data and plotting separate. Reasons: there are many plotting methods (gnuplot ...); it is easy to call the data-building function from within a plotting function. Of course, fmesh() can be called from any other plotting function, but still I'd rather keep code for plotting separate. Otoh, since you propose many calling methods (below), the code for determing the boundaries, the size of the grid etc would have to be repeated in the plotting and in the data-building function (and repetition of code isn't fun). So one function could be better in that respect. # fmesh(x,y,'fn') - use the given x and y grid spacing # # fmesh(...,[xmin xmax ymin ymax]) - use the given axis limits # # fmesh(...,n) - use the given number of steps in each dimension x, y # # z = fmesh(...) - return the mesh rather than plotting # # [x,y,z] = fmesh(...) - return the mesh and the mesh spacing # # fmesh(...,'loop') - don't vectorize the expression, but instead evaluate # it once for each point in x cross y. Other question: 'loop' by default, or not? Also, the user may want to provide an already vectorized expression. I did not provide an auto-vectorize feature, but let the user put the '.'. I thought there may be some cases where there are some matrix products that shouldn't be .-prefixed. [snip] # To distinguish between expression and function use: # # if all(isalnum(expr)), z=feval(expr,x,y); else eval(["z=",expr,";"]); end Should check for "x" and "y" too. # To vectorize we will need a function which converts bare ^ and * to .^ and .*. # This would be something like: # # expr = strrep(expr,'*','.*'); # expr = strrep(expr,'^','.^'); # expr = strrep(expr,'..','.'); Beware of trailing "..." [snip] # I would put it in main/plot. # # What do you think? Don't know, there's no rush so I'll let the question rest. Cheers, Etienne -- Etienne Grossmann ------ http://www.isr.ist.utl.pt/~etienne |