Unrecognized function or variable 'del'.
조회 수: 1 (최근 30일)
이전 댓글 표시
n=0;
>> for del=0.0:0.4:pi
n=n+1;
pe(n)=1.2*sin(del);
댓글 수: 0
답변 (3개)
ScottB
2024년 6월 10일
del is a native function:
Try renaming your variable. You also need and "end" statement at the end of your loop.
댓글 수: 0
Star Strider
2024년 6월 10일
That should actually work —
tic
n = 0;
for del=0.0:0.4:pi
n=n+1;
pe(n)=1.2*sin(del);
end
toc
pe
A mnore efficient implementation would be —
tic
del=0.0:0.4:pi;
for n = 1:numel(del)
pe(n) = 1.2*sin(del(n));
end
toc
pe
However you can take advantage of MATLAB vectorisation capabilities and just use —
tic
del=0.0:0.4:pi;
pe = 1.2*sin(del);
toc
pe
The vectorisation approach is morst efficient in this instance (and likely others as well).
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!