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 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 20 Jul 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.

More Answers (0)

Categories

Find more on MATLAB 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!