How to plot an angle (theta) vs Current for the following question

I am new to Matlab.
I wanted to find the Torque given as T= A*I*cos(theta) - B*I.^2*sin(2*thetha)
with A= 0.01 B= 0.001; I varies from 0 to 100 and thetha from 0 to 45.
I want to find the maximum T (Torque) and plot I vs Theta
This my basic syntax:
A=0.01; %Wb is the unit of A
B=0.001; %H is the unit of Inductance
I=(0:10:100);
theta=(0:1:45);
T=A*I.Cos(theta)-B*I.^2*Sin(2*theta);

 Réponse acceptée

A=0.01; %Wb is the unit of A
B=0.001; %H is the unit of Inductance
I =(0:10:100); %row!
theta=(0:1:45).'; %column!
T = A .* I .* cosd(theta) - B .* I.^2 .* sind(2*theta);
surf(I, theta, T)
xlabel('I'); ylabel('theta'); zlabel('Torque')
[maxT, idx] = max(T(:));
[r,c] = ind2sub(size(T), idx);
best_theta = theta(r);
best_I = I(c);
fprintf('best torque is %g at theta = %g and I = %g\n', maxT, best_theta, best_I);
best torque is 1 at theta = 0 and I = 100

7 commentaires

This result is predictable by looking at the equation.
For maximum, you want to subtract off as little as possible, so you prefer that B .* I.^2 .* sind(2*theta) be 0 (if you are confined to the first quadrant) or as negative as possible (if you have access to other quardants.). You do not permit access to the other quadrants, but the expression can be 0 if 2*theta == 0, which is theta == 0.
For maximum, you want the first term to be as large as possible. With theta being 0, cosd(theta) is 1, which is large as possible for it. A is constant. So for maximum value you want I to be as large as is permitted.
You can thus predict that the maximum torque will be at maximum I and at angle 0, unless you have access to other quadrants.
Yes Walter, Absolutely agree with your explanation. This is a MPTA algorithm. So it uses negative theta for having use of both the terms in the equation. The first term is the magnetic torque which happens to be maximum at 0 degree, where cos0 = 1 ; where as we also need reluctance torque the second term, with maximum value at 45 degree.
But here it shows maximum as 1, so to increase the torque should we put the theta values from 0 to -45 degree
I did not get usage of idx in [maxT, idx] = max(T(:));
T is a 2d array of values. We want to know the row and column where the maximum occurs. But max() cannot return the row and column of the location of the maximum: it can only return the linear index of the maximum. So we have to take the linear index and convert it to row and column after.
There is a different way to handle this that does not require converting linear index, but it requires building a grid of input values instead of using implicit expansion such as I did here.
You mean to say using meshgrid?
Yes, using meshgrid. You can avoid using ind2sub() -- but you still end up using linear indexing.
A=0.01; %Wb is the unit of A
B=0.001; %H is the unit of Inductance
I_vec =(0:10:100);
theta_vec = (0:1:45);
[I, theta] = meshgrid(I_vec, theta_vec);
T = A .* I .* cosd(theta) - B .* I.^2 .* sind(2*theta);
surf(I, theta, T)
xlabel('I'); ylabel('theta'); zlabel('Torque')
[maxT, idx] = max(T(:));
best_theta = theta(idx);
best_I = I(idx);
fprintf('best torque is %g at theta = %g and I = %g\n', maxT, best_theta, best_I);
best torque is 1 at theta = 0 and I = 100

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by