Answer to Question #305533 in MatLAB for Mr Z

Question #305533

On the same figure plot all four obtained powers in kW against time. Use different line styles for each power, e.g. solid line, dashed line, dotted line or dash-dot line. Add labels to all axes. Add title, legend and grid to the figure.


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]);




1
Expert's answer
2022-03-04T12:31:45-0500
close all,
clear all,
clc,

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