my plot is blank?

1 次查看(过去 30 天)
Elizabeth
Elizabeth 2023-5-26
my graph is generated but there are no lines that appear on the graph
clear;
close all;
clc;
%load the cross section distance along river
rivercrossection = load('Cross_Sections_DistanceAlongRiver_X_Y.txt', '\t');
% load the pre-dredging cross sections
pre_dredging_crossection = load("PreDredgingCS.txt");
pre_dredging_crossection = reshape(pre_dredging_crossection, [], 1);
%load post-dredging cross section
post_dredging_crossection = load("PostDredgingCS.txt");
post_dredging_crossection = reshape(post_dredging_crossection, [], 1);
% Calculate the volume of sediment using the detailed cross section
volume_crossection = sum(post_dredging_crossection - pre_dredging_crossection) * (rivercrossection(2) - rivercrossection(1)) * (pre_dredging_crossection(2) - pre_dredging_crossection(1));
% Calculate the velocities pre dredging
velocitiesB1 = (200 / (rivercrossection(2) - rivercrossection(1))) * (pre_dredging_crossection(2) - pre_dredging_crossection(1)) / (pre_dredging_crossection);
%calculate the velocities post dredging
velocitiesB2 = (200 / (rivercrossection(2) - rivercrossection(1))) * (post_dredging_crossection(2) - post_dredging_crossection(1)) / (post_dredging_crossection);
% Plot the current velocities for the cross section
figure(2);
plot(velocitiesB1,velocitiesB2,'b-');
xlabel("transect");
ylabel("Current velocity (m/s)");
title("Current velocities before and after dredging");

回答(2 个)

Cris LaPierre
Cris LaPierre 2023-5-26
There are 3 things to check right away
  1. that your variable velocitiesB1 and velocitiesB2 are not empty
  2. that those variables have at least 2 values
  3. that those values are not NaN
If you are plotting a single point, you won't be able to see it because your plot style does not include a marker style. Add one to see if this is the case.
plot(velocitiesB1,velocitiesB2,'b-*');

Image Analyst
Image Analyst 2023-5-26
What does this show in the command window?
whos velocitiesB1
whos velocitiesB2
plot(velocitiesB1,velocitiesB2,'b-*');

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by