フィルターのクリア

Why is my Plot Blank?

1 回表示 (過去 30 日間)
Anna Bernbaum
Anna Bernbaum 2016 年 10 月 24 日
回答済み: Thorsten 2016 年 10 月 25 日
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))

回答 (2 件)

Roger Stafford
Roger Stafford 2016 年 10 月 24 日
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 2016 年 10 月 25 日
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);

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by