Dimension Mismatch in loop, for some values the amount of iterations does not equal the dimensions of the matrix of outputted valued (eg. V = 300 D = 5)

조회 수: 3 (최근 30일)
V = input('Input Volume\n'); D = input('Input Diameter\n');
A = ((D/2)^2)*pi; %Area H = V/A; %Height g = 9.81; %Gravity
y = [H:-0.1:0];
v = 1;
for i = H:-0.1:0 VELOCITY = sqrt(2*g*i); x(v) = VELOCITY; v =v+1;
end
plot(x,y) title('Velocity vs. Height in Tornicelli''s Law') xlabel('Velocity (meters per second)') ylabel('Height (meters)')
  댓글 수: 3
Ahmed Emam
Ahmed Emam 2017년 10월 19일
I figured out the problem, because I ran it multiple times without clearing the workspace first some values caused the error

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by