Dear Andreas,

you are right. I forgot to define gmax. It's my fault :)

Anyway the solution you suggested in your previous post works perfectly, so 
thank you very much for answering. 

Michela



Il giorno martedì 21 aprile 2015 18:35:28 UTC+2, Andreas Noack ha scritto:
>
> Hi Michela
>
> It is easier to help if your example is complete such that it can just be 
> pasted into the terminal. The variable gmax is not defined in your example, 
> but I guess it is equal to length(SUC_C). It is also useful to provide the 
> exact error message.
>
> That said, I think the root of the problem is the dependency between the 
> loop variable in the comprehension. The loop variable r depends on the 
> other loop variable j which is not allowed in comprehension. A solution 
> could be to preallocate suc, e.g. something like
>
> suc = zeros(length(SUC_C), length(tau_max))
> for j = 1:length(SUC_C)
>     for r = 1:tau_max[j]
>         suc[j,r] = SUC_C[j]*(1 - 1/(r+1))
>     end
> end
>
> 2015-04-21 12:21 GMT-04:00 Michela Di Lullo <michela...@uniroma1.it 
> <javascript:>>:
>
>> Hello everyone, 
>>
>> I'm trying to declare the following matrix:
>>
>> suc=[SUC_C[j]*(1-1/(r+1)) for j=1:gmax, r=1:tau_max[j]]
>>
>> whereas: 
>>
>> SUC_C=[6661.09, 8236.1, 7619.48, 8462.68, 5705.73, 6040.87]
>>
>> tau_max=[4,4,3,2,1,4]
>>
>> but it's not working. 
>>
>> Any idea about how to make it correctly? 
>>
>> Thanks for any info,
>>
>> Michela
>>
>
>

Reply via email to