How would I write a function that uses the function I have to plot A and V versus a for 0.25 <= a <= 4 inches.

1 vue (au cours des 30 derniers jours)
function [V, A] = calc(a)
if (a > 4)
if (a < 0.25)
V = 1/4 * pi * ((a+(a+2)) * ((a+2)-a) ^ 2);
A = pi ^ 2 * ((a+2) ^ 2 - a ^ 2);

Réponse acceptée

Walter Roberson
Walter Roberson le 19 Avr 2011
function [V,A] = calc(n)
a = linspace(0.25,4,n);
V = 1/4 .* pi .* ((a+(a+2)) .* ((a+2)-a) .^ 2);
A = pi ^ 2 .* ((a+2) .^ 2 - a .^ 2);
plot(a,V,a,A);
The input, n, is the number of subdivisions to use along 0.25 to 4. Or to be more correct, n is the total number of points to use in the plot, including the two end-points.

Plus de réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by