repetitively running the code and selectively plotting
1 回表示 (過去 30 日間)
古いコメントを表示
I am a new learner of Matlab and I am trying to learn to code with the loops. I am stucking with a problem.
I have table "a" which has multiple rows and 2 columns of table in matlab. I attached the file here.
1st column is time and 2nd column is data (q).
I want to make a loop for 6000 rows each and generate plot (data vs time). Before generating plots I want the user to see the starting time of each loop (the time from row 1,6001,12001) and let the user to decide the specific time to generate the specific plot related to that time.
I know my code is a lot of lacking and I am doing self learning. Can somebody help me out?
u = 1:1:6000 % I want to make it loop automatically from 1 to 100 but i don't know how
r = a.Time(u)
for i = 1:1:r
figure
plot
plot(a.t(i),a.q(i))
title(sprintf('Selling vs time from %s', ),r)
xlabel('time')
ylabel('selling $')
end
回答 (1 件)
Image Analyst
2022 年 10 月 28 日
First use readmatrix or readtable to read in the data and plot the whole thing with a single call to plot. Then use input to ask the user what part they want to plot. Then in your loop you need to plot one marker and then call hold on
plot(a.t(i), a.q(i), 'b.', 'MarkerSize', 8);
hold on;
5 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!