Info

この質問は閉じられています。 編集または回答するには再度開いてください。

how do I place the text on the first co ordinate of the plot?

1 回表示 (過去 30 日間)
Madhuri
Madhuri 2017 年 9 月 27 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I am potting trajectories of vehicles (time-space plots) and following is my code %% Read data table = readtable('E:\vehdata11.xlsx'); VehicleNos = unique(table.VehicleID);
%% Plotting
for idx = 1:numel(VehicleNos) n = VehicleNos(idx); sb = table(table.VehicleID == n,:); labels=cellstr(num2str(n)); Time= sb.time; x = sb.time; y = sb.x; tin = min(x); t1 = x - tin; y1 = t1*11.04; y2 = y - y1;
%% plotting for time interval
i = (Time>20 & Time<=25);
plot(x(i),y2(i))
hold on
text(max(x(i)),max(y2(i)),labels)
end Now the position of text is on the maximum (x,y) coordinate But since my graph is not linear and fluctuating I want the labels to be on the first co ordinate text(x(1), y(1),labels) is not working. How do I do that?

回答 (1 件)

Andrew Bliss
Andrew Bliss 2017 年 9 月 27 日
What error do you get? Or what do you mean "is not working"? Check the values of x(1) and y(1) and make sure they're not NaN or outside your graph axis.
  1 件のコメント
Madhuri
Madhuri 2017 年 9 月 27 日
I assigned x=x(i) and y=y(i) and then used text(x(1),y(1), labels).It says index exceeds matrix dimensions and also shows error in text command.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by