Those are 1D vectors, not 2D arrays. Matt's solution will work fine on them. I don't know why you said it works with one row - I ran your code and it didn't work (but with Matt's fix it works). How did you get that to work????? In fact I believe Matt's fix should also work for arrays of any dimension since it uses linear indexing.
4 Comments
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54184#comment_112057
How about you give an example of when it's an array so we can help you?
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54184#comment_112068
This are array: G=[1;0;2;3;0]; Tsol=[11; 12; 13;14;15]; Tamb=[10;15;16;16;12]
The final resultant neet to be: Tsol= 11 15 13 14 12 in stead of 11 12 13 14 15 the 12 and 15 are change and comes from Tamb
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54184#comment_112071
Those are 1D vectors, not 2D arrays. Matt's solution will work fine on them. I don't know why you said it works with one row - I ran your code and it didn't work (but with Matt's fix it works). How did you get that to work????? In fact I believe Matt's fix should also work for arrays of any dimension since it uses linear indexing.
Direct link to this comment:
http://www.mathworks.com/matlabcentral/answers/54184#comment_112074
The solution is: Tsol(G==0) = Tamb(G==0);