- /
- 
        working of dc motor using MATLAB
        on 30 Oct 2024
        
        
 
    - 10
- 82
- 0
- 0
- 908
 Cite your audio source here (if applicable): 
drawframe(1);
 Write your drawframe function below
function drawframe(frameNumber)
    % Parameters
    numPoles = 4; % Number of magnetic poles
    rotorRadius = 1; % Radius of the rotor
    coilLength = 0.5; % Length of the coil representation
    % Create figure
    figure;
    hold on;
    axis equal;
    axis([-1.5 1.5 -1.5 1.5]);
    title(['DC Motor Operation - Frame ' num2str(frameNumber)]);
    % Draw the stator poles
    theta_poles = linspace(0, 2*pi, numPoles+1); % Angles for poles
    for i = 1:numPoles
        % Calculate position for the poles
        x_pole = 1.2 * cos(theta_poles(i));
        y_pole = 1.2 * sin(theta_poles(i));
        % Alternate North and South poles
        if mod(i, 2) == 1
            text(x_pole, y_pole, 'N', 'FontSize', 14, 'FontWeight', 'bold', 'HorizontalAlignment', 'center');
        else
            text(x_pole, y_pole, 'S', 'FontSize', 14, 'FontWeight', 'bold', 'HorizontalAlignment', 'center');
        end
    end
    % Draw the rotor
    theta_rotor = deg2rad(frameNumber * 10); % Rotate rotor by frameNumber*10 degrees
    x_rotor = rotorRadius * cos(theta_rotor);
    y_rotor = rotorRadius * sin(theta_rotor);
    % Draw coil arms of the rotor
    line([-x_rotor, x_rotor], [-y_rotor, y_rotor], 'Color', 'r', 'LineWidth', 2);
    plot(x_rotor, y_rotor, 'bo', 'MarkerFaceColor', 'b'); % Rotor position
    % Magnetic field indication (simple arrow from one pole to opposite)
    quiver(0, 0, 0.5 * cos(theta_rotor + pi/2), 0.5 * sin(theta_rotor + pi/2), ...
           'k', 'LineWidth', 1, 'MaxHeadSize', 1);
    % Display text
    xlabel('X-axis');
    ylabel('Y-axis');
    grid on;
    hold off;
end


 

