I am trying to use the matlab function on my simulink model to model Voltage that is a function of vibration from my piezoelectric source. I wrote the code below but the code analyzer doesnt seem to read the function call line. How do I fix this?

2 visualizzazioni (ultimi 30 giorni)
function Vpiezo=fcn(vib)
w=12;
b=1;
h=0.4;
e31=11.2;
e33=(8.85*10^(-12))*1800;
delta=0.1;
L=5;
R=delta/(b*L*e33*w);
Vpiezo=(w*b*h*e31*R*vib)/(2(1+(b*L*e33*((w*R)/delta))));
end

Risposta accettata

Walter Roberson
Walter Roberson il 20 Lug 2020
Vpiezo=(w*b*h*e31*R*vib)/(2(1+(b*L*e33*((w*R)/delta))));
^^
In MATLAB, the syntax 2(something) is an attempt to index the constant 2 with the content of the expression. This is not permitted sytax in MATLAB.
Note; MATLAB has absolutely no implied multiplication. If you want multiplication in MATLAB, you must always use the .* or * operation as appropriate to the circumstances.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by