Array Preallocation

I am trying to preallocate an array that can be filled with any type of value string, double, int mostly. What am I doing wrong because I'm getting an error:
l = 300;
w = 13;
full_data=cell(l, w);
This is the error:
??? Subscripted assignment dimension mismatch.

댓글 수: 3

Trader
Trader 2012년 3월 29일
I should clarify... after I've allocated the array, I try writing to it like this:
counter is just an integer that increments through a loop.
full_data(counter,:) = {...13 values ...}
Thomas
Thomas 2012년 3월 30일
Can you show your {..13 values.. }
Trader
Trader 2012년 3월 31일
full_data(counter,:) = {counter current_date current_time position pa bp num_shares entry_price price sma t_band goshort l_band golong profit};
counter = int
current_date = serial num of date mm/dd/yy
current_time = serial num of time HH:MM
position = int
everything else = double
thanks for you help!

댓글을 달려면 로그인하십시오.

답변 (1개)

Thomas
Thomas 2012년 3월 28일

0 개 추천

your code works correctly and preallocates memory correctly
l = 300;
w = 13;
full_data=cell(l, w);
>> size(full_data)
ans =
300.00 13.00
Try clearing the variables before you begin.
doc clear

댓글 수: 1

Matt Tearle
Matt Tearle 2012년 3월 28일
Perhaps you have a variable called "cell"...?

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Performance and Memory에 대해 자세히 알아보기

질문:

2012년 3월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by