-3
为什么我的matlab函数不能绘图?每当我输入一个变量时,我的matlab图中都没有出现任何线条。需要帮助:Matlab函数绘图
下面的代码:
%we have decided to emulate an auditory sensor
function GroupSensorFun1(N) %user chooses # of variables
%creating sensor data for time and decibles
timeVec = 1:1:N; %vector emulates N seconds
soundVec = 1000/rand(N,1) %randomly generates N readings
hold on
for i = 1:N %loop N times to plot all data
%plot data on to scatter graph one varible at a time.
%scatter(timeVec(i),soundVec(i))
plot(timeVec(i),soundVec(i))
end
% Create xlabel
xlabel({'Time in Seconds'});
% Create ylabel
ylabel({'Decibles scaled'});
% Create title
title({'Auditory Sensor Data in ', num2str(N) ' Seconds'});
hold off
你真的需要for循环吗?我的意思是你不能简单地使用'plot(timeVec,soundVec)'? –
请勿使用双倍空间码。这很难阅读。 –
如果没有一组可重现的数据,我们如何判断您是否试图绘制NaN或Infs? –