Clear Filters
Clear Filters

Why the plot figure is empty

1 view (last 30 days)
Zhiying Wang
Zhiying Wang on 1 Nov 2019
Answered: Walter Roberson on 2 Nov 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 Comments
Walter Roberson
Walter Roberson on 1 Nov 2019
You cannot do that.
Steven Lord
Steven Lord on 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?

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 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

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!