Borrar filtros
Borrar filtros

Why the plot figure is empty

1 visualización (últimos 30 días)
Zhiying Wang
Zhiying Wang el 1 de Nov. de 2019
Respondida: Walter Roberson el 2 de Nov. de 2019
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 comentarios
Walter Roberson
Walter Roberson el 1 de Nov. de 2019
You cannot do that.
Steven Lord
Steven Lord el 1 de Nov. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 2 de Nov. de 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

Categorías

Más información sobre Data Distribution Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by