Error using fsurf (too many functions) but success using ezsurf
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Austin Vander Linden
il 22 Nov 2019
Commentato: Walter Roberson
il 7 Gen 2023
When using the fsurf command to plot this function, I recieve the message: "error using fsurf, too many functions."
By simply changing "fsurf" to "ezsurf" I successfully get my 4 figures (intended to model tumors).
I understand there is a difference in the plotting methods of fsurf and ezsurf, and I assume that fsurf, if correctly used, would give me more detailed figures. What could be causing the discrepancy? I appreciate any and all help!
syms u v
for a = 3:4
for b = 5:6
figure
fsurf((1+1/5*sin(a*u)*sin(b*v))*sin(v)*cos(u),(1+1/5*sin(a*u)*sin(b*v))*sin(v)*sin(u),(1+1/5*sin(a*u)*sin(b*v))*cos(v),[0 2*pi 0 pi])
end
end
0 Commenti
Risposta accettata
madhan ravi
il 22 Nov 2019
Modificato: madhan ravi
il 22 Nov 2019
Just vectorize the function and use function handles. To learn the proper usage of the functions that get you into a dilemma is to read the documentation page of the function.
fsurf(@(u,v)(1+1/5*sin(a*u).*sin(b*v)).*sin(v).*cos(u),(1+1/5*sin(a*u).*sin(b*v)).*sin(v).*sin(u),(1+1/5*sin(a*u).*sin(b*v)).*cos(v),[0 2*pi 0 pi]) % just alter your line to this line
doc fsurf % to open the documentation of the function
However I'm not getting the same error message that you're getting and it's not familiar.
2 Commenti
Più risposte (1)
Balu
il 5 Gen 2023
Convert your interval argument to a double
fsurf(f, double(plot_range))
MATLAB doesn't always evaluate the final values of expressions. For example, you used 2*pi in your code. This has to be evaluated to 6.28. But if MATLAB finds it suitable, it can decide to just leave it as 2*pi and evaluate later when needed. But when your expressions are not evaluated, I think your plot range is considered a vector function. By doing double(plot_range), you get a scalar array, which is what fsurf needs.
4 Commenti
Balu
il 7 Gen 2023
Modificato: Balu
il 7 Gen 2023
@WalterRoberson I'd expect that to be the case for any programming language, but it doesn't appear that MATLAB is rigorous enough to do that.
When I have a range matrix of unevaluated expressions, I find that the double function is necessary to avoid the too many functions error from fsurf.
>> plot_range
[-pi/20, (11*pi)/20, -5, 5]
>> f
f =
sin(x)^20
>> fsurf(f, plot_range)
Error using fsurf
Too many functions.
>> fsurf(f, double(plot_range))
>>
MATLAB version: 9.13.0.2145394 (R2022b) Update 3
Walter Roberson
il 7 Gen 2023
Ah, what is going on there is that you have defined your plot_range symbolically (you are getting symbolic π there), and your f is symbolic as well. Your fsurf(f,plot_range) is then passing two symbolic expressions to fsurf(), which is only expecting one symbolic expression. The range does need to be numeric (not symbolic) for fsurf(). But this has nothing to do with "vector function" or "scalar array".
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!