Question about plot results


#1

Hi,

assume that we set the sensor to all points in the network.
To figure out the results, should I place the number of sensors instead of 5?

sensor_id = G.getNodeNameID 

num=length(sensor_index) > then repalce 5 with num, is it true?Will I get the right results?

%% Plot results
for i = 1:Ns
    for j = 1:length(sensor_index)
      subplot(5,1,j)
      plot(Q{i}.Time/24/60/60, Q{i}.Quality{j}(:,1),'-','Color',[0,0.7,0.9]); hold on; grid on
    end
end
for i = 1:length(sensor_index)
   subplot(5,1,i)
   title(sensor_id{i})
   ylabel('Cl_2 (mg/L)')
   xlabel('Time (days)')
end

Thanks in advance


#2

when I used the above code I got this error,

Error using subplot (line 327)
Index exceeds number of subplots.

Error in simulation (line 60)
   subplot(5,1,j)

How can i fix it?
Thanks,
Thomas


#3

Hi @mollerth try this

%% Plot results
for i = 1:Ns
    for j = 1:length(sensor_index)
      subplot(length(sensor_index),1,j)
      plot(Q{i}.Time/24/60/60, Q{i}.Quality{j}(:,1),'-','Color',[0,0.7,0.9]); hold on; grid on
    end
end
for i = 1:length(sensor_index)
   subplot(length(sensor_index),1,i)
   title(sensor_id{i})
   ylabel('Cl_2 (mg/L)')
   xlabel('Time (days)')
end

That’s ok for me.

I hope this help

Best,
ken