Help to plot a graph using the data file

81 views (last 30 days)
Ruthra
Ruthra on 5 Dec 2025 at 10:06
Commented: Star Strider on 6 Dec 2025 at 17:18
I have the data filefor the velocity, for which i need aplot a graph.

Answers (1)

Star Strider
Star Strider on 5 Dec 2025 at 11:14
Perhaps something like this --
writematrix([0:10; sin(2*pi*(0:10)/20)].','Your_Data.csv') % Create File
Data = readmatrix('Your_Data.csv') % Read File
Data = 11×2
0 0 1.0000 0.3090 2.0000 0.5878 3.0000 0.8090 4.0000 0.9511 5.0000 1.0000 6.0000 0.9511 7.0000 0.8090 8.0000 0.5878 9.0000 0.3090 10.0000 0.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Time = Data(:,1);
Velocity = Data(:,2);
figure
plot(Time, Velocity)
grid
axis('padded')
xlabel('Time')
ylabel('Veolcity')
title('Data')
.
  19 Comments
Sam Chak
Sam Chak on 6 Dec 2025 at 16:28
Edited: Sam Chak on 6 Dec 2025 at 16:33
Upon re-examining the situation, I believe that the identically named data files are "unprocessed" and retrieved from different folders categorized by varying AR values, as most systems do not permit two files with the exact same name and extension in the same folder. This likely explains why @Ruthra uploaded the data files across three separate comments above.
Some legacy machines or MATLAB codes may generate default filenames in this manner. In contrast, modern approaches typically create sequential filenames with the date and time appended to the end of the sequential number. This practice is generally beneficial for sorting data files chronologically.
Therefore, I sincerely believe that the code may need to be adjusted to account for @Ruthra's actual situation, and should post in a new Answer.
However, your solution to work with identically named files deserves a vote! 👍
Star Strider
Star Strider on 6 Dec 2025 at 17:18
@Sam Chak -- Thank you!
Copying the complete paths to each file to create the'filec' cell array would then only require changing:
ufile = websave('uvelo-vor', filesc{ki});
u{k} = readmatrix(ufile);
and:
vfile = websave('vvelo-vor', filesc{ki});
v{k} = readmatrix(vfile);
to:
u{k} = readmatrix(filesc{ki});
and:
v{k} = readmatrix(filesc{ki});
in their appropriate loops, respectively.
The rest is unchanged.
.

Sign in to comment.

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!