Borrar filtros
Borrar filtros

Why is my Plot Blank?

1 visualización (últimos 30 días)
Anna Bernbaum
Anna Bernbaum el 24 de Oct. de 2016
Respondida: Thorsten el 25 de Oct. de 2016
Hi, my code returns a blank plot and I dont know why
Code:
beta1 = 0.1
theta = [0: 0.1: 90];
function dyds = motorbike(betas)
for theta = [0: 0.1: 90]
a = 3/(8*betas);
b = sqrt(8*(sind(theta)).^2 + 1);
c = sind(theta)*(cosd(theta)).^3;
dyds = a*(b/c);
end
%dyds = (3/(8*betas))*sqrt((8*sin(theta).^2)+1)/sin(theta)*cos(theta).^3;
end
figure
plot(theta, motorbike(beta1))

Respuestas (2)

Roger Stafford
Roger Stafford el 24 de Oct. de 2016
You need to index dyds so that it contains a value for each value of ‘theta’:
dyds = zeros(1,length(theta));
for k = 1:length(theta)
...
b = sqrt(8*(sind(theta(k))).^2 + 1);
c = sind(theta(k))*(cosd(theta(k))).^3;
dyds(k) = a*(b/c);
end

Thorsten
Thorsten el 25 de Oct. de 2016
You don't need the for loop, you can work on the vector beta. You just have to replace * and / with .* and ./ (you already use .^)
betas = 0.1
theta = [0: 0.1: 90];
a = 3/(8*betas);
b = sqrt(8*(sind(theta)).^2 + 1);
c = sind(theta).*(cosd(theta)).^3;
dyds = a.*(b./c);

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by