% Create a time vectort = 0:0.001:1; % Time from 0 to 1 second with a step of 0.001 seconds% Create a sine wave for voltagefrequency = 50; % Frequency of the sine wave in Hzamplitude = 220; % Amplitude of the sine wave in voltsvoltage = amplitude * sin(2 * pi * frequency * t); % Calculation of the sine wave% Create a square wave for currentdutyCycle = 50; % Duty cycle of the square wave (percentage)current = amplitude * square(2 * pi * frequency * t, dutyCycle); % Calculation of the square wave% Plot the voltage waveformsubplot(2, 1, 1);
plot(t, voltage);
title('Voltage Waveform');
xlabel('Time (s)');
ylabel('Voltage (V)');
% Plot the current waveformsubplot(2, 1, 2);
plot(t, current);
title('Current Waveform');
xlabel('Time (s)');
ylabel('Current (A)');
780 chars
26 lines
This MATLAB code creates a sine wave for voltage and a square wave for current with a frequency of 50 Hz and an amplitude of 220 volts. It then plots these two waveforms on separate subplots.