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 (최근 30일)
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
Steven Lord
Steven Lord 2020년 4월 10일
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.

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

답변 (1개)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020년 4월 12일
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!

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by