Figure box does not show data when using plot(x,y)
1 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Line Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!