can someone explain line 13,14?
If I remove that I am getting a blank plot

 채택된 답변

Torsten
Torsten 2023년 8월 13일
편집: Torsten 2023년 8월 13일

0 개 추천

Why ?
In order to plot a time-location curve after the while-loop, the intermediate results for time and location are saved in two separate vectors.

댓글 수: 6

Vigneshwaran
Vigneshwaran 2023년 8월 13일
So the vector gets updated each time or the values get appended each time? I mean what will be the dimension of that vector after each iteration and also by the time loop terminates?
Torsten
Torsten 2023년 8월 13일
편집: Torsten 2023년 8월 13일
So the vector gets updated each time or the values get appended each time?
The new values for t and y get appended each time to the vectors "time" and "location".
I mean what will be the dimension of that vector after each iteration and also by the time loop terminates?
The dimension of the two vectors "time" and "location" is the number of times the while loop has been executed. Thus the final dimension cannot be told right at the beginning - it depends on the time when y becomes negative.
Vigneshwaran
Vigneshwaran 2023년 8월 14일
Understood,Thank you.
Vigneshwaran
Vigneshwaran 2023년 8월 15일
time=0
time=[time:t]
In 1st iteration
time=[0:0.1]
In 2nd iteration
time=[[0:0.1]:0.2]
Is this the way?
Torsten
Torsten 2023년 8월 15일
time = 0;
time = [0 ; 0.1]
time = [0 ; 0.1 ; 0.2];
...
Image Analyst
Image Analyst 2023년 8월 15일
Again, it's recommended not to use the name of built-in functions, such as time, as your variable names.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2023년 8월 13일
편집: Image Analyst 2023년 8월 13일

0 개 추천

Don't use time as the name of your variable since it's a built-in function. Call it "theTime" or something.
Don't have line 20 - no need to plot twice.
Have lines 13 and 14 come before lines 11 and 12.
Have line 17 say
whos theTime % Display size of vector
whos location
plot(theTime, location, 'r-', 'LineWidth', 2);
grid on;
Post your code as code/text (not an image) if you need any more help after you read this:

댓글 수: 2

Vigneshwaran
Vigneshwaran 2023년 8월 14일
OK, Thanks for the info will follow from next time.
Image Analyst
Image Analyst 2023년 8월 14일
My advice can be followed this time, on this program. No need to wait until next time (next program).

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2023년 8월 13일

댓글:

2023년 8월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by