# Need to correct the matlab code for the question.

조회 수: 1(최근 30일)
Vipul 2022년 10월 8일
댓글: Vipul 2022년 10월 8일
Write the Matlab code for the above question.
I have written the following code, but there is some error..after Power=Torque*angular velocity.
Error in code, "Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses. "
Power=Torque*angular velocity
clc;clear all;close all;
w=1000:10:6000;
%Engine 1
a=0.03;
b=7.5e-6;
T=torque(w,a,b);
P=T*2*pi.*w/60;
figure(1)
plot(w,T,'LineWidth',1.5)
hold on
figure(2)
plot(w,P/1000,'LineWidth',1.5)
hold on
%Engine 2
a=0.02;
b=3.333e-6;
T=torque(w,a,b);
P=T*2*pi.*w/60;
figure(1)
plot(w,T,'LineWidth',1.5)
figure(2)
plot(w,P/1000,'LineWidth',1.5)
%Engine 3
a=0.015;
b=1.875e-6;
T=torque(w,a,b);
P=T*2*pi.*w/60;
figure(1)
plot(w,T,'LineWidth',1.5)
xlabel('{\omega}(rpm)')
ylabel('Torque (Nm)')
title('Torque Vs speed')
legend('Engine 1','Engine 2','Engine 3')
figure(2)
plot(w,P/1000,'LineWidth',1.5)
xlabel('{\omega}(rpm)')
ylabel('Power (kW)')
title('Power Vs speed')
legend('Engine 1','Engine 2','Engine 3')
function T=torque(w,a,b)
T=120+a*(w-1000)-b*(w-1000).^2;
end

댓글을 달려면 로그인하십시오.

### 채택된 답변

Ghazwan 2022년 10월 8일
clc;clear all;close all;
w=1000:10:6000;
%Engine 1
a=0.03;
b=7.5e-6;
T=torque(w,a,b);
P=T*2*pi.*w/60;
figure(1)
plot(w,T,'LineWidth',1.5)
hold on
figure(2)
plot(w,P/1000,'LineWidth',1.5)
hold on
%Engine 2
a=0.02;
b=3.333e-6;
T=torque(w,a,b);
P=T*2*pi.*w/60;
figure(1)
plot(w,T,'LineWidth',1.5)
figure(2)
plot(w,P/1000,'LineWidth',1.5)
%Engine 3
a=0.015;
b=1.875e-6;
T=torque(w,a,b);
P=T*2*pi.*w/60;
figure(1)
plot(w,T,'LineWidth',1.5)
xlabel('{\omega}(rpm)')
ylabel('Torque (Nm)')
title('Torque Vs speed')
legend('Engine 1','Engine 2','Engine 3')
figure(2)
plot(w,P/1000,'LineWidth',1.5)
xlabel('{\omega}(rpm)')
ylabel('Power (kW)')
title('Power Vs speed')
legend('Engine 1','Engine 2','Engine 3')
function T=torque(w,a,b)
T=120+a*(w-1000)-b*(w-1000).^2;
end
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Vipul 2022년 10월 8일
I tried, but there is another here down
for following line
>> T=torque(w,a,b);
Unrecognized function or variable 'torque'.

댓글을 달려면 로그인하십시오.

### 범주

Find more on Lighting, Transparency, and Shading in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by