# Plotting error 'Data must be numeric, datetime, duration or an array convertible to double.'

4 views (last 30 days)
Garrett on 20 May 2021
Answered: Walter Roberson on 20 May 2021
Hi all,
Im trying to plot 3 different values (ai,Gamma,cl) on the same plot vs. y (from -3 to 3) but i keep getting an error that im not sure how to resolve. Im quite a novice at matlab so im sure theres somehting obvious that im just not seeing, but any help is greatly appreciated. Thanks in advance.
clc
clear
N = 19;
AR = 6;
n =1:2:N;
b = 6;
Vinf = 1;
c = 1;
deltay = b./(N+1);
y0n = -(b./2)+n.*deltay;
syms alpha
A = sym('A', [1, N]);
A = A(1:2:end);
Pi = sym(pi);
theta = (linspace((Pi/6),(Pi/2),numel(n)).');
S1 = sum(A.*sin(n.*(theta)));
S2 = sum(n.*A.*(sin(n.*(theta))./sin((theta))));
eq1 = (2*AR/pi)*S1+S2 == alpha;
[A,b] = equationsToMatrix(eq1, A);
x = linsolve (A,b);
An = vpa(x)
ai = sum(n.*A.*(sin(n.*(theta))./sin((theta))));
Gamma0 = ai*2*b*Vinf;
Gamma = Gamma0*sqrt(1-(2*y0n./b).^2);
cl = 2*pi*(10-ai);
y = linspace(-3,3,10);
plot (ai,y,'r',Gamma,y,'g',cl,y,'b')

Walter Roberson on 20 May 2021
An = vpa(x)
You calculate x and An, but you do not do anything with them.
[A,b] = equationsToMatrix(eq1, A);
b is going to be full of the unresolved variable alpha that you use as the right hand side of eq1 . (Note, by the way, that all of your right hand sides of eq1 are the same. Not impossible, but questionable.)
Gamma0 = ai*2*b*Vinf;
b is full of alpha, as mentioned, so Gamma0 is going to be multiples of alpha
Gamma = Gamma0*sqrt(1-(2*y0n./b).^2);
with the 1- portion, even though some of the expression divides by b (which is alpha) canceling out some alpha from Gamma0, there will still be some alpha remaining -- alpha * (A+B/alpha) still has alpha*A in it.
Also, you have not defined alpha as real-valued or positive, so sqrt(1/b^2) would not generally be 1/b -- it would be 1/abs(b) even if there were not other terms interfering with the division being "clean"
y = linspace(-3,3,10);
plot (ai,y,'r',Gamma,y,'g',cl,y,'b')
You seem to be exchanging x and y for those plots, in that your y is independent rather than your x.
Anyhow: as indicated your Gamma involves the unresolved variable alpha. You cannot use plot() with symbolic variables involving unresolved variables.
If you are wanting alpha to vary according to y, then you will need to use subs(Gamma,alpha,y)