[Scilab-users] submatrix issue

antoine monmayrant antoine.monmayrant at laas.fr
Fri Jun 1 11:55:07 CEST 2018


Hello,


What do you wan to achieve exactly?
As Stéphane pointed out, the sizes are not the same.
When you assign something like:

A=B;

You have two different situations:

1) size(A)==size(B)
2) size(B)=[1,1]

In the first case, you assign each element of B to each element of A. In 
the latter case (which corresponds to your commented line), B is just a 
scalar that gets assigned to each element of A.

In the current situation, you are neither in case 1) nor in case 2).
As you have size(NodesMatrix2(i,j+1))=[300,300] and 
size(resu(k))=[300,1], you might want to replicate resu(k) 300 times and 
fill NodesMatrix2(i,j+1) with these 300 copies. If this what you want to 
do, here is the code:

NodesMatrix2(i,j+1)=resu(k)*ones(1,300);


By the way, why do you use "evstr(resu(k))" instead of "resu(k)"?


Antoine


Le 01/06/2018 à 11:45, Stéphane Mottelet a écrit :
> It cannot work since
>
> --> size(k)
>  ans  =
>
>    300.   1.
>
>
> --> length(i)*length(j)
>  ans  =
>
>    90000.
>
> i.e. NodesMatrix2(i,j+1) has 90000 elements and resu(k) has 300
>
> S.
>
> Le 01/06/2018 à 11:07, Carrico, Paul a écrit :
>>
>> Dear all
>>
>> I’ve a submatrix issue on the following example, and I do not 
>> remember (or understand) why : how can I do this ?
>>
>> (the goal is to extract and to store within a matrix results from an 
>> Ascii file)
>>
>> Thanks for any help
>>
>> Paul
>>
>> ###############################################################
>>
>> mode(0)
>>
>> clearall
>>
>> StartNodeLine= 1;
>>
>> NumberOfNodes= 100;
>>
>> DimCoordinates= 3;
>>
>> resu= rand(1000,1);
>>
>> tic();
>>
>> NodesMatrix2= zeros(NumberOfNodes,DimCoordinates+1);
>>
>> i= [1 : NumberOfNodes]'; NodesMatrix2(i,1) = 
>> _evstr_(resu(StartNodeLine + (DimCoordinates+2)*(i-1)+2));
>>
>> i= [1 : NumberOfNodes]'.*.ones(1,DimCoordinates)';
>>
>> j= ones(1,NumberOfNodes)'.*.[1 : DimCoordinates]';
>>
>> k= StartNodeLine + (DimCoordinates+2)*(i-1)+3+j;
>>
>> a= _evstr_(resu(k));
>>
>> NodesMatrix2(i,j+1)= _evstr_(resu(k)); /// does not work/
>>
>> ///NodesMatrix2(i,j+1) = 1; // work(basic assignement)/
>>
>> Duration2= toc()
>>
>> */EXPORT CONTROL :
>> /**Cet email ne contient pas de données techniques
>> This email does not contain technical data*
>>
>>
>>
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users 
>>
>
>
>
>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180601/8cec05ed/attachment.htm>


More information about the users mailing list