Hello,
I'm new here and doesn't got the proc-Syntax from the docu(https://de.mathworks.com/help/symbolic/mupad_ug/procedures.html) running. I tried different syntaxes and removed the ':' after end_proc because it caused additional syntax-errors. I'm using matlab R2016b
The syntax error says 'Undefined function or variable 'calc_TCU''
TCU=zeros(1,10);
calc_TCU := proc(index,time,I)
begin
TCU_gain=TCU(index-1)+time/t_max2(I*10-9);
TCU_end=I*(1-0.8)/(1.15*7);
TCU(index)=(TCU_gain-TCU_end)*(2.71)^(-t/(87.4*3))+TCU_end;
end_proc

 Akzeptierte Antwort

Steven Lord
Steven Lord am 16 Nov. 2016

0 Stimmen

Are you trying to write this in the MATLAB Editor or in the Command Window? That section of the documentation deals with the MuPAD interface in Symbolic Math Toolbox and the code to create a procedure will work only in a MuPAD notebook. Instead, to write a section of code you can run repeatedly with input aguments in MATLAB write a function.

2 Kommentare

Sören Kwasigroch
Sören Kwasigroch am 16 Nov. 2016
it was the Matlab Editor. Ok, then procedure aren't meant for simple scripts. Thanks. Then I try to write the same in a function
Steven Lord
Steven Lord am 16 Nov. 2016
proc is meant to define procedures in the MuPAD notebook interface. The equivalent in MATLAB is a function. But if you just want to group commands together and don't need to pass input arguments to them, you can create a script file instead of a function file. Click on "Programming Scripts and Functions" on the left side of the page to which I linked then click on "Create Scripts" on the page that comes up for information on script files.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Aliou Thiam
Aliou Thiam am 26 Apr. 2022

0 Stimmen

percol_aiguilles := proc(p)
local i, j, x, y, n, angle, pts, lignes, longueur, liste_pts,
liste_lignestemp, liste_lignes, liste;
n := stats[random, poisson[p]](1);
for i to n do
x[i] := evalf(1/1000000000000*rand());
y[i] := evalf(1/1000000000000*rand());
pts[i] := disk([x[i], y[i]], 0.005, color = black);
angle := 1/1000000000000*Pi*rand();
lignes[i] := line([evalf(x[i] - 0.1*cos(angle)),
evalf(y[i] - 0.1*sin(angle))],
evalf(x[i] + 0.1*cos(angle)),
evalf(y[i] + 0.1*sin(angle))], color = black,
thickness = 1)
end do;
for i to n do liste_pts := [seq(pts[i], i = 1 .. n)] end do;
for i from 2 to n do for j to i do
longueur :=sqrt((x[i] - x[j])^2 + (y[i] - y[j])^2);
if longueur < 1/1000000000000*rand() then
lignes[i, j] := line([x[i], y[i]],
[x[j], y[j]], color = black, thickness = 2)
else lignes[i, j] := line([x[i], y[i]],
[x[j], y[j]], color = gray, thickness = 1)
end if end do end do;
plots[display]([seq(lignes[i], i = 1 .. n), op(liste_pts)],
view = [0 .. 1, 0 .. 1], axes = normal, scaling = constrained)
end proc

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by