is this form of code is correct?

1 回表示 (過去 30 日間)
Aniket
Aniket 2013 年 3 月 7 日
Hello,
i have written some code for my simulation as following
for i = 1:10
phi(i)= [phi num2str(i)](end)
end
but in matlab it is showing me error
Error: File: initialconditinsanotherform.m Line: 12 Column: 29
Unbalanced or unexpected parenthesis or bracket.
the error is showing for (end) bracket
what should i do?
i am trying to get end values from previous simulation to my next simulation as an initial values.
Thank You,

採用された回答

Jan
Jan 2013 年 3 月 7 日
編集済み: Jan 2013 年 3 月 7 日
for k = 1:10
v = [phi num2str(k)];
phi(k) = v(end)
end
But this is a really strange operation: Why do you create the vector v when you need the last element only? And what might be the reason for num2str? The result of the function will be the string:
phi = '01234567890';
or perhaps the corresponding ASCII values.
  1 件のコメント
Aniket
Aniket 2013 年 3 月 7 日
Hello Jan,
I am doing simulation in simulink and and i am declaring initial values in Matlab. The simulation are related to oscillators and each oscilator is having integrators because its ODE equations.
for example i have 3 oscillators, so i have to define initial values phi (1), phi(2), phi(3) each phi value is define for 1,2,3 oscillators respectively.
so i have create a vector in matlab like phi = [1 1 1]
this is for first time simulation ... after first time simulation there will be some different output values and i want to use these values as an initial values for my second time simulation.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGeneral Applications についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by