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

 採用された回答

Steven Lord
Steven Lord 2016 年 11 月 16 日

0 投票

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 件のコメント

Sören Kwasigroch
Sören Kwasigroch 2016 年 11 月 16 日
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 2016 年 11 月 16 日
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.

サインインしてコメントする。

その他の回答 (1 件)

Aliou Thiam
Aliou Thiam 2022 年 4 月 26 日

0 投票

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

タグ

質問済み:

2016 年 11 月 16 日

回答済み:

2022 年 4 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by