Azzera filtri
Azzera filtri

Why is my Plot Blank?

1 visualizzazione (ultimi 30 giorni)
Anna Bernbaum
Anna Bernbaum il 24 Ott 2016
Risposto: Thorsten il 25 Ott 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))

Risposte (2)

Roger Stafford
Roger Stafford il 24 Ott 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 il 25 Ott 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);

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by