Figure box does not show data when using plot(x,y)

3 ビュー (過去 30 日間)
Zachary Smith
Zachary Smith 2019 年 7 月 17 日
回答済み: David K. 2019 年 7 月 17 日
When I run this script a figure box appears, but no lines appear. When I change plot(x,y) to scatter(x,y) the data appears correctly. Why won't plot(x,y) plot the data as a line? I am trying to plot the average pixel value of an image over time in two separate figures.
clear all
data = importdata('BSPB_09_DIC1.mat');
figure
for i = 1:102
y = mean2(data.data_dic_save.strains(i).plot_exx_ref_formatted(87:151,83:151));
x = i*4;
plot(x,y), hold on
end
figure
for i = 1:102
y = mean2(data.data_dic_save.strains(i).plot_eyy_ref_formatted(87:151,83:151));
x = i*4;
plot(x,y), hold on
end

採用された回答

David K.
David K. 2019 年 7 月 17 日
The reason is that you are trying to create a plot with a single data point multiple times. So each time you plot there are not two points for the plot function to connect.
A simple change is to make y and x y(i) and x(i) then plot outside the for loops.
With Matlab you can probably throw out the for loops altogether with matrices:
figure
i = 1:102;
y = mean2(data.data_dic_save.strains(i).plot_exx_ref_formatted(87:151,83:151));
x = i*4;
plot(x,y)

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by