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 Ansicht (letzte 30 Tage)
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);

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 19 Apr. 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.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by