Storing Integer Values in Matlab?

3 ビュー (過去 30 日間)
Kevin
Kevin 2014 年 7 月 21 日
回答済み: Azzi Abdelmalek 2014 年 7 月 21 日
Hi,
I am using the following for loop:
for TSR=1:0.1:10
and am storing values as follows:
store_F(:,TSR)=F;
store_sigma(:,TSR)=sigma;
store_Phi(:,TSR)=Phi;
store_TSR_local(:,TSR)=TSR_local;
store_axial_induction(:,TSR)=axial_induction;
However I am getting the following error:
Subscript indices must either be real positive integers or logicals.
Error in BEM (line 100) store_F(:,TSR)=F;
Could anybody please help with this as I am unsure how to store integer values? Thanks.

回答 (2 件)

Robert Cumming
Robert Cumming 2014 年 7 月 21 日
you loop is going from 1 to 10 in steps of 0.1 (which is allowed).
However you are using your loop indicator is an index in a variable, i.e on the first loop:
store_F(:,1) = F % thats ok - you are populating column 1
2nd loop:
store_F(:,1.1) = F % thats not allowed - you cant populate column 1.1...
You need to index your column by integers.

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 21 日
What you need to do is
ii=0;
for TSR=1:0.1:10
ii=ii+1;
store_F(:,ii)=F;

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by