-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? –