how to express a set

sir, my problem is i want to write ai belongs to A(1<=i<=N) where A={a1,a2,...aN}in matab.i have written this like:
for A=1:N;
if (1<=i<=N)
ai=A;
end
end
i am new to matlab .plz tell me this is right or wrong and if it's wrong then what to write..
Expecting a favorable reply.
Thanking u SUCHI

1 件のコメント

Andy
Andy 2011 年 5 月 16 日
It is very unclear what you're trying to do, but it looks like you have a cell array A which is a vector of length n, and you want to have variables a1, a2, ..., an representing each element of your cell array. Is this correct? If so, don't do this. It is much better to keep your data in a cell array A and refer to it as A{i} rather than ai. Perhaps you should refer to http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F.

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

 採用された回答

Andrei Bobrov
Andrei Bobrov 2011 年 5 月 16 日

1 投票

ai = A(1:N);

3 件のコメント

suchismita
suchismita 2011 年 5 月 16 日
hello mr.andrei.
when i am trying the expression u ve suggest i am getting the error like below.u ve suggest me to write ai = A(1:N); to express a set.
??? Undefined function or method 'A' for input arguments of type 'double'.
Error in ==> maximum_life at 24
ai = A(1:N);
pllzz help.
regards SUCHI
Andrei Bobrov
Andrei Bobrov 2011 年 5 月 17 日
Error in "maximum_life" at line 24,
variable A - undefined.
Her need defined.
Oleg Komarov
Oleg Komarov 2011 年 5 月 17 日
i.e. you have do define A (and N) before calling ai = A(1:N);
otherwise is the same as saying "tell me the true lottery numbers that are gonna be drawn tomorrow"

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

その他の回答 (0 件)

カテゴリ

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by