Why the plot figure is empty
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
y = ones(1,11,'sym');
syms a;
n=0;
for x = -a/2:a/10:a/2;
n=n+1;
y(n)=(15/8*a)^(1/2)*(1-4*x^2/a^2);
end
fplot(-a/2:a/10:a/2,y)
I want to plot y=(15/8*a)^(1/2)*(1-4*x^2/a^2), x is from -a/2 to a/2.
Why the figure is empty? There is Warning: Error updating ParameterizedFunctionLine. The following error was reported evaluating the function in FunctionLine update: Non-scalar in Uniform output, at index 1, output 1.
Set 'UniformOutput' to false.
4 Kommentare
Steven Lord
am 1 Nov. 2019
I want the final plot contains a, instead of setting a value for a
You can't. Let's say a was 1. What does your y function look like?
>> syms a x
>> y = (15/8*a)^(1/2)*(1-4*x^2/a^2);
>> vpa(subs(y, a, 1))
ans =
1.369306393762915283642424457002 - 5.477225575051661134569697828008*x^2
What if a was -1 instead?
>> vpa(subs(y, a, -1))
ans =
- x^2*5.477225575051661134569697828008i + 1.369306393762915283642424457002i
In general you can't even say whether or not y is a real-valued or complex-valued function! How would you expect MATLAB to plot the function under those circumstances?
Antworten (1)
Walter Roberson
am 2 Nov. 2019
How about this:
for a = linspace(0,5,20)
x = -a/2:a/10:a/2;
y = -((4*x.^2)/a^2 - 1)*((15*a)/8).^(1/2);
plot3(x,y,repmat(a,1,length(x)),'displayname', num2str(a));
hold on;
end;
hold off
view(3)
legend show
0 Kommentare
Siehe auch
Kategorien
Mehr zu Conversion Between Symbolic and Numeric finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!