What code would you input to represent the equation for the volume of a sphere without getting an undefined variable error?
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Risposta accettata
John D'Errico
il 19 Giu 2016
Modificato: John D'Errico
il 19 Giu 2016
Easy, peasy.
V=(4*pi*r.^3)/3;
I added a semi-colon at the end, and I used .^ for the exponent, in case r is an array or vector.
Since you apparently are getting an undefined variable error, then you need to tell us more.
My guess is, you actually want to create a function of the radius, so that r is indeed undefined at the time you create the function.
V= @(r ) (4*pi*r.^3)/3;
Or possibly, you want to create this in symbolic form. In that case, you need to define r as symbolic.
help syms
How can we know what is in your mind?
4 Commenti
John D'Errico
il 19 Giu 2016
Yes, you must not have that TB. Within limits, you COULD use my sympoly toolbox. It is on the File Exchange. It is admittedly limited though.
Più risposte (2)
Tarence Glasker
il 22 Set 2017
how to input equation into matlab function tan(x/2) = sort(1-cos(x) / 1+cos(x);?
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!