How to give an initial value to a variable in simulink "matlab function"

The input is "hitin" and the output is "hitout" (on the right-hand side of M function),which is saved as matrix HIT. However, I want to give an initial value to variable,"hitin". i uses "memory" but it has compiling error! If i am right the result of HIT is supposed to be 1 9 9 9 9 .... Hoping somebody can help me.

回答 (1 件)

Niklas Nylén
Niklas Nylén 2014 年 4 月 1 日

0 投票

It looks like the reason for the compile error is that hitout may not be set at all, for example if hitin = -1.
Change the elseif condition to an else condition and the compile error should disappear.

3 件のコメント

SHINCHEN
SHINCHEN 2014 年 4 月 1 日
I appreciate,but still have Make error(weird): C:\Users\Kaiser's\Desktop\Passive Walking\bipedal\Kobetest_sfun.mexw64 could not be deleted. Trying to delete again. Two attempts to delete C:\Users\Kaiser's\Desktop\Passive Walking\bipedal\Kobetest_sfun.mexw64 have failed. This file is either not writable or is locked by another process.
Niklas Nylén
Niklas Nylén 2014 年 4 月 1 日
Close Matlab, delete Kobetest_sfun.mexw64, start matlab and run again.
SHINCHEN
SHINCHEN 2014 年 4 月 5 日
Sorry!I missed your answer. It is still not working. But thanks alot!

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2014 年 4 月 1 日

コメント済み:

2014 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by