Plot all the rain drops on the window when the time is 0 s (i.e. at the start of the journey) using a FOR loop. The plot should be contained exactly in the perimeter of the window and the rain drops should be represented as solid blue lines that conn

1 view (last 30 days)
HOW CAN I SOLVE THE FOLLOWING?
Plot all the rain drops on the window when the time is 0 s (i.e. at the start of the journey) using a FOR loop. The plot should be contained exactly in the perimeter of the window and the rain drops should be represented as solid blue lines that connect the corresponding start and end nodes
  4 Comments
Steven Lord
Steven Lord on 10 Apr 2020
This sounds like a homework assignment. If it is, show us the code you've written to try to solve the problem and ask a specific question about where you're having difficulty and we may be able to provide some guidance.
If you aren't sure where to start because you're not familiar with how to write MATLAB code, I suggest you start with the MATLAB Onramp tutorial (https://www.mathworks.com/support/learn-with-matlab-tutorials.html) to quickly learn the essentials of MATLAB.
If you aren't sure where to start because you're not familiar with the mathematics you'll need to solve the problem, I recommend asking your professor and/or teaching assistant for help.

Sign in to comment.

Answers (1)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi on 12 Apr 2020
Hello!
There are clearly a lot of moving pieces in this question, and it is unclear where exactly it is that you want help. However, at least from the title of the question, it seems like you want to read data from a given .txt file, load it into MATLAB and plot a line connecting the start and end coordinates, using a for loop.
Here it goes -
dataIn = readmatrix('filenameXYZ.txt'); % Read data from given .txt file
xA = dataIn(:,1); % X-Coordinates of A
yA = dataIn(:,2); % Y-Coordinates of A
xB = dataIn(:,3); % X-Coordinates of B
yB = dataIn(:,4); % Y-Coordinates of B
% Use for loop to iterate through all rows and plot data
for i=1:size(dataIn,1)
% Plot line between A & B points using their coordinates
plot([xA(i),xB(i)], [yA(i),yB(i)]);
% Plot on the same figure
hold on
end
Documentation Links:
  • readmatrix: Link
  • Matrix Operations & Indexing: Link
  • plot: Link
As mentioned by @Steven earlier, MATLAB Onramp courses are a great way to kickstart your journey with MATLAB.
Hope this helps!

Tags

Community Treasure Hunt

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

Start Hunting!