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. "

457 Ansichten (letzte 30 Tage)
clear
clc
m1=1;
m2=0.5;
m3=0.2;
rp=87;
R1=rp-r1;
R2=rp-r2;
R3=r3-rp;
l=2.27;
r2=[58.7 27.8 20 59 30 31.2 68.5 67 34 60 39 50.3 50 45.3 45]';
r3=[12.89 20.65 226 120 217 193.1 91.6 110 197.5 166 158.3 142.1 150 176.5 122]';
Rb=(((1/2).1)-rp);
x=R2
y=R3
G=x;
G(:,2) = ones(length(x), 1);
delta = G \ y
slope=delta(1,1)
intercept=delta(2,1)
m_b = m2./Rb.*slope-(m1./Rb).*R1
sigma = sqrt(sum((y-x).^2)./(length(x)-1));
se1 = sigma.*sqrt(1./((length(x)+mean(y)^2/((length(x)-1)*std(x)^2))));
se2 = sigma.*sqrt(1./((length (x)-1)*std(x)^2));
Ci1=tinv(.975,length(x)-1).*se1;
Ci2=tinv(.975,length(x)-1).*se2;
% creating a line of best fit
X = [min(x);1e-3;max(x)]';
Y = delta(1,1) + delta(2,1).*X;
SE=sigma.*sqrt(1/length(x)+(X-mean(x)).^2./((length(x)-1)*std(x).^2));
Ci=tinv(.975,length(x)-1).*SE;
figure(1)
clf
plot(m1, m2, 'ob')
hold on
% plotting the conidence intervals
plot (X, Y, 'R')
plot(X,Y+Ci,'g--')
plot(X,Y-Ci,'g--')
hold off
xlabel('$$-$$','interpreter','latex')
ylabel('$$-)$$','interpreter','latex')
print(figure(1), '-dpng', 'figure1')
  1 Kommentar
Walter Roberson
Walter Roberson am 10 Dez. 2018
You have a "clear" so there cannot be anything in your workspace after that.
Then you define R1=rp-r1; without having assigned anything to r1. Is r1 a function? Likewise for r2 and r3 at the point of assignment? You redefine r2 and r3 after that point, which gets confusing.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 10 Dez. 2018
Rb=(((1/2).1)-rp);
You do not have an operator between the (1/2) and the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4=((xaq^2)-xaq*xfq)/Dq;
Aq5=((xaq^2)-xq*xaq)/Dq;
Aq6=(xq*xfq-(xaq^2))/Dq;
U=1;
Ufd=34;
Ufq=0;
theta=2.4*pi/180;
cos(theta);
IFD=diff(ifd(t), t) == Ad1*U*cos(theta)-Ad2*(Ufd-rfd*ifd(t))-Aq3*rkd*ikd(t);
IFQ=diff(ikq(t) ,t)== Aq4*U*cos(theta)-Aq5*(Ufq-rfq*ifq(t))-Aq6*rkq*ikq(t);
IKD=diff(ikd(t) ,t)== Ad4*U*cos(theta)-Ad5*(Ufd-rfd*ifd(t))-Ad6*rkd*ikd(t);
IKQ=diff(ikq(t) ,t)== Aq4*Ucos(theta)-Aq5*(Ufq-rfq*ifq(t))-Aq6*rkq*ikq(t);
sistem (IFD, IFQ, IKD, IKQ) sistem=evalf(%5);
with(DEtools);
DEplot([IFD, IKD], [x1(t), x3(t), t=0..15, x1=-14..14, x3=-4..4, [[x1(0)=.99, x3(0)=0.1]], arrows=medium);
Error: File: Xarakteristika.m Line: 69 Column: 29
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or
other syntax error. To construct matrices, use brackets instead of parentheses.

EN XIN NEO
EN XIN NEO am 23 Mär. 2021
Name='Corrective with MTTR'
Type='mamdani'
Version=2.0
NumInputs=4
NumOutputs=1
NumRules=15
AndMethod='min'
OrMethod='max'
ImpMethod='min'
AggMethod='max'
DefuzzMethod='centroid'
[Input1]
Name='Budget'
Range=[0 100]
NumMFs=3
MF1='low':'trimf',[0 0.006955 20]
MF2='medium':'trimf',[20 30 50]
MF3='high':'trimf',[50 71 100]
[Input2]
Name='Frequency'
Range=[0 12]
NumMFs=3
MF1='low':'trapmf',[0 0 2 3]
MF2='medium':'trapmf',[2 3 4 5]
MF3='high':'trapmf',[4 5 12 13]
[Input3]
Name='Age'
Range=[0 30]
NumMFs=3
MF1='Young':'trapmf',[-10 0 9 10]
MF2='Mid-Age':'trapmf',[9 10 15 16]
MF3='Old':'trapmf',[15 16 30 31]
[Input4]
Name='MTTR';
Range=[0 5];
NumMFs=4;
MF1='Low':'trapmf',[-1.607 0 1.607 2]
MF2='Medium':'trapmf',[1.5 1.606577 2.7748402 3]
MF3='High':'trapmf',[2.6 2.774803 3.226124 3.3]
MF4='Very_High':'trapmf',[3.1 3.226 5 6]
[Output1]
Name='Corrective_Maintenance'
Range=[0 4]
NumMFs=3
MF1='low':'trimf',[0 1 1.5]
MF2='medium':'trimf',[1.5 2 2.5]
MF3='high':'trimf',[2.5 3 3.5]
[Rules]
1 1 0 0, 1 (1) : 1
3 3 0 0, 3 (1) : 1
0 3 0 0, 3 (1) : 1
0 1 0 0, 1 (1) : 1
1 1 1 0, 1 (1) : 1
3 3 3 0, 3 (1) : 1
3 3 2 0, 3 (1) : 1
1 3 2 0, 3 (1) : 1
3 3 2 0, 3 (1) : 1
1 1 3 0, 3 (1) : 1
3 1 3 1, 3 (1) : 1
1 1 3 1, 3 (1) : 1
3 2 1 4, 2 (1) : 1
2 3 1 2, 3 (1) : 1
3 3 3 3, 3 (1) : 1
This is my coding in mfile, it shows this error: Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets
instead of parentheses. Where should I amend

Suganthi D
Suganthi D am 22 Okt. 2021
clc;
clear all;
close all;
disp('Household consumption data');
filename=input('enter the file name:','s');
eval(filename);
% serial number devices name Power rating(Watts) No.of equipments Average hours/Day daily energy consumption(Watts)
Household_consumption_House1=[1 "tubelight" 40 5 6 240
2 "Electric Iron" 750 1 0.5 300
3 "Water heater/Geyser" 2000 1 0.5 1000
4 "Refrigerator" 150 1 24 3600
5 "table fan/ceiling fan" 75 4 10 750
6 "Air- conditioner" 1560 1 5 7800
7 "Exhaust-fan" 150 1 1 150
8 "Washing Machine" 400 1 1 400
9 "Television" 100 1 8 800
10 "Wet-grinder" 300 1 2 600
11 "computer" 200 1 8 1600
12 "Motor 1 Hp" 740 1 1 740];
Total_energy_consumption_House1= sum(daily_energy_consumption);
plot( hours, energy consumption,'r');
xlabel('Time (Hours)');
ylabel('Energy consumption (kW)');
title('daily load profile of House 1')
Good Evening sir,
I am creating the energy consumption on individual house but i got error could you please help me to resolve the problem sir..
I got this error sir..
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax
error. To construct matrices, use brackets instead of parentheses.

vittal pandu
vittal pandu am 12 Dez. 2021
Bearbeitet: Walter Roberson am 12 Dez. 2021
% Enter your MATLAB code below
readChannelID = 1598383;
fieldID1 = 1;
readAPIkey = 'W5OMOQ1VN14DH9Q6';
returnPatientHealthMonitoringSystem = thinkSpeakRead(readChannelID, 'field', fieldID1, 'Readkey', readAPIkey)
[Pulse Rate in BPM, temperatue] = returnPatientHealth(returnPatientHealthMonitoringSystem);
plotPatientHealth(Pulse Rate in BPM, temperatue)
function plotPatientHealth(Pulse Rate in BPM, temperatue)
vertices = [0 0; 1 0; 1 1; 0 1];
faces = [1 2 3 4];
faceColorPatchLUT = [0 0.83 0; 0.44 0.95 0.52; 1 0.98 0.53; 0.95 0.98 0.22; 1 0.39 0.39; 1 0 0];
facecolorPatch = facecolorPatchLUT(temperatue,:);
PatientHealthPatch = patch('Faces', faces, 'vertices', vertices, 'facecolor', facecolorPatch);
hold on
text(0.5,0.5,Pulse Rate in BPM,'Fontsize',16,'HorizontalAlignment','centre')
hold off
axHandle = PatientHealthPatch.Parent;
axHandle.YTickLabel = [];
axHandle.XTickLabel = [];
end
function plotPatientHealth[Pulse Rate in BPM, temperatue] = returnPatientHealth(returnPatientHealth)
PatientHealth = {'Good';'Moderate';'Severe(should have a health check-up)'}
PatientHealthlow = [0;51;101;151;201;300;500];
PatientHealthhigh = [50,100,150,200,300,500];
lutPatientHealth = table(PatientHealth,PatientHealthlow,PatientHealthhigh,'varialbleNames',{'Patient_Health','PatientHealth_low','PatientHealth_high'})
temperatue = find(returnPatientHealth >= lut.PatientHealth_low & returnPatientHealth <= lut.PatientHealth_high)
PatientHealth = string(lutPatientHealth.Patient_Health(temperature))'
end
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
This is the error it's showing
  1 Kommentar
Walter Roberson
Walter Roberson am 12 Dez. 2021
function plotPatientHealth[Pulse Rate in BPM, temperatue] = returnPatientHealth(returnPatientHealth)
That line is not valid MATLAB syntax.
When you have a function line, if you have an =, then the left side of the = can be a single MATLAB identifier, or it can be a comma-separated list of identifiers in [] .
You have an identifier followed by something in [] . You cannot have anything indexed on the left side of a = for a function statement. Also, Pulse Rate in BPM is not a valid MATLAB identifier name.
function plotPatientHealth(Pulse Rate in BPM, temperatue)
The names there must be valid MATLAB identifier names. Pulse Rate in BPM is not a valid MATLAB identifier.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by