Normalized graph not showing

Hello all,
I'm encountering an issue with plotting lines in MATLAB, and I'm seeking some assistance in resolving it.
I have a timeseries object out.Q_i_nd containing ice torque data over time. I'm attempting to plot the normalized ice torque values against time for multiple ice torque data series. However, despite executing the code, the lines representing the data are not visible in the plot.
Here's the relevant snippet of my MATLAB code:
% Extract data from the timeseries object
ice_torque_data = out.Q_i_nd.Data; % Extract ice torque data
time_range = out.Q_i_nd.Time; % Assuming time is stored in the Time property
Q_max = 7.408e5; % Define Q_max value
% Plot the normalized ice torque
figure;
hold on;
for i = 1:size(ice_torque_data, 2)
plot(time_range, ice_torque_data(:,i) / Q_max); % Plot the normalized ice torque in blue
end
xlabel('Time');
ylabel('Normalized Ice Torque (out.Q_i_nd / Q_{max})');
title('Comparison of Normalized Ice Torque with Q_{max}');
grid on;
legend('Normalized Ice Torque');
I've already ensured that the data ranges and y-axis limits are appropriate, and I've attempted to increase the line width. Despite these efforts, the lines remain invisible on the plot.
Could you please offer some insights into why the lines aren't showing up on the plot and suggest potential solutions?
Thank you in advance for your assistance!

3 件のコメント

Dyuman Joshi
Dyuman Joshi 2024 年 3 月 7 日
You most likely have NaN (or NaT) values in your data.
In any case, please share your data, use the paperclip button to attach.
Miku Sevón
Miku Sevón 2024 年 3 月 7 日
Hi,
Data is now attached.
Dyuman Joshi
Dyuman Joshi 2024 年 3 月 11 日
Any updates, @Miku Sevón? Did you check the answer @Star Strider posted?

サインインしてコメントする。

回答 (1 件)

Star Strider
Star Strider 2024 年 3 月 7 日

0 投票

The timeseries ‘out.Q_i_nd.Data’ is a 3D matrix. You need to use the squeeze function to remove the extra singleton dimensions.
Then, it works —
load('out.mat')
% whos
% out
% out.Q_i_nd.Data
% Extract data from the timeseries object
ice_torque_data = squeeze(out.Q_i_nd.Data); % Extract ice torque data
time_range = out.Q_i_nd.Time; % Assuming time is stored in the Time property
Q_max = 7.408e5; % Define Q_max value
% Plot the normalized ice torque
figure;
hold on;
for i = 1:size(ice_torque_data, 2)
plot(time_range, ice_torque_data(:,i) / Q_max); % Plot the normalized ice torque in blue
end
xlabel('Time');
ylabel('Normalized Ice Torque (out.Q_i_nd / Q_{max})');
title('Comparison of Normalized Ice Torque with Q_{max}');
grid on;
legend('Normalized Ice Torque');
.

カテゴリ

ヘルプ センター および File Exchange2-D and 3-D Plots についてさらに検索

製品

リリース

R2023b

タグ

質問済み:

2024 年 3 月 7 日

コメント済み:

2024 年 3 月 11 日

Community Treasure Hunt

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

Start Hunting!

Translated by