Doubt in a program

5 views (last 30 days)
Vigneshwaran
Vigneshwaran on 13 Aug 2023
Commented: Image Analyst on 15 Aug 2023
can someone explain line 13,14?
If I remove that I am getting a blank plot

Accepted Answer

Torsten
Torsten on 13 Aug 2023
Edited: Torsten on 13 Aug 2023
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 Comments
Torsten
Torsten on 15 Aug 2023
time = 0;
time = [0 ; 0.1]
time = [0 ; 0.1 ; 0.2];
...
Image Analyst
Image Analyst on 15 Aug 2023
Again, it's recommended not to use the name of built-in functions, such as time, as your variable names.

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 13 Aug 2023
Edited: Image Analyst on 13 Aug 2023
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 Comments
Vigneshwaran
Vigneshwaran on 14 Aug 2023
OK, Thanks for the info will follow from next time.
Image Analyst
Image Analyst on 14 Aug 2023
My advice can be followed this time, on this program. No need to wait until next time (next program).

Sign in to comment.

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!