Answer to Question #303946 in MatLAB for MR Z

Question #303946

2. Plot each variable listed below against time in a form of subplot. There should be 6 subplots in a single figure aligned in 2 columns and 3 rows. Use different line colour for each data. Add labels to all axes.


• time in seconds [Time]


• speed in km/h [Speed]


• gear [Gear]


• elevation in meters [Elv]


• SOC (state-of-charge) in % [SOC]


• battery voltage in V [Pack Volts]


• battery current in A [Pack Amps]


1
Expert's answer
2022-02-28T08:29:59-0500
close all,
clear all,
clc,


%{
    Use the battery voltage and current data imported to calculate the battery power P as follows 
    P = UI where P is the battery power [W], U is the battery voltage [V] and I is the battery current 
    [A] battery voltage in V [Pack Volts]
    battery current in A [Pack Amps]  
 2. Plot each variable listed below against time in a form of subplot. 
    There should be 6 subplots in a single figure aligned in 2 columns and 3 rows. 
    Use different line colour for each data. Add labels to all axes.
    • time in seconds [Time]
    • speed in km/h [Speed]
    • gear [Gear]
    • elevation in meters [Elv]
    • SOC (state-of-charge) in % [SOC]
    • battery voltage in V [Pack Volts]
    • battery current in A [Pack Amps]
%}




t = 0:1:100;    %Time Step
Load = 10;  % Ohms


P=[];       %power
Vel = [];   %Speed
Gear= [];   %Gear
SOC = [];   %Soc
V = [];     %Voltage
A = [];     %Current
for r=1:length(t)
    V(r)=100*rand;
    A(r) = V(r)/Load;
    P(r) = V(r) * A(r);
    Vel(r) = V(r)*rand();
    SOC(r) = Vel(r)*rand;
    Gear(r) = SOC(r)*rand();
end
scrsz = get(0,'ScreenSize');
Dim=0;
figure('Position',[scrsz(1)+Dim, scrsz(2)+Dim,scrsz(3)-20,scrsz(4)-100]);


subplot(3,2,1);
plot(t,V,'r');  grid on,    hold on,
xlabel('--- Time(t) --->');
ylabel('--- Voltage (V) --->');
title('Plot: Voltage','FontSize',20);


subplot(3,2,2);
plot(t,A,'g');  grid on,    hold on,
xlabel('--- Time(t) --->');
ylabel('--- Current(A) --->');
title('Plot: Current (A)','FontSize',20);


subplot(3,2,3);
plot(t,P,'b');  grid on,    hold on,
xlabel('--- Time(t) --->');
ylabel('--- Power --->');
title('Plot: Power','FontSize',20);


subplot(3,2,4);
plot(t,Vel,'k');  grid on,    hold on,
xlabel('--- Time(t) --->');
ylabel('--- Speed --->');
title('Plot: Speed','FontSize',20);


subplot(3,2,5);
plot(t,SOC,'m');  grid on,    hold on,
xlabel('--- Time(t) --->');
ylabel('--- SOC --->');
title('Plot: SOC','FontSize',20);


subplot(3,2,6);
plot(t,Gear,'c');  grid on,    hold on,
xlabel('--- Time(t) --->');
ylabel('--- Gear --->');
title('Plot: Gear','FontSize',20);




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS