my plot is blank?

1 Ansicht (letzte 30 Tage)
Elizabeth
Elizabeth am 26 Mai 2023
Beantwortet: Image Analyst am 26 Mai 2023
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");

Antworten (2)

Cris LaPierre
Cris LaPierre am 26 Mai 2023
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 am 26 Mai 2023
What does this show in the command window?
whos velocitiesB1
whos velocitiesB2
plot(velocitiesB1,velocitiesB2,'b-*');

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by