필터 지우기
필터 지우기

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 CenterFile Exchange에서 2-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