Replace matrix elements with zero apart from specific vectors
Show older comments
Hello,
I have 8 vectors, N1 to N8 which belong to a bigger matrix (2x28000). Four of the N-vectors are 1x3 and the other four are 1x41.
I want to replace the values of the big matrix with zeros apart from those belonging to the N-vectors.
I managed to extract the N-vectors from the bigger matrix using findNodes in PDE toolbox, e.g.:
'N1 = findNodes(model.Mesh,"region","Edge",1);'
But what I actually need is the whole bigger matrix with only the N-vectors values (and all the others =0) instead of just the N-vectors.
Hope it is clear.
Any idea on the method?
Thank you so much.
6 Comments
the cyclist
on 11 Jul 2023
What you want is unclear to me.
Can we create a smaller toy example, to understand the concept better? Suppose I just have
N1 = [2 3 5];
N2 = [7 11 13];
N3 = [17 19 23 29]; % Using 1x4, instead of 1x41, for simplicity
Give me an example of what the bigger input matrix looks like (maybe just using 2x12), and what the desired output would be.
Stefano Russo
on 11 Jul 2023
Dyuman Joshi
on 11 Jul 2023
So, for the example you posted, you want to replace [4 5 6 7] in the array x with 0?
Stefano Russo
on 11 Jul 2023
dpb
on 11 Jul 2023
But by what logic is one to know which elements to replace is the Q? still indeterminate. You can replace any value by any other; the problem is having a way to generate the indices of the locations to change programmatically.
I scanned through the whole conversation and don't see anywhere that is defined; you start out with something that is 2xN and some other vectors of some size that don't seem somehow related to that dimension and when @the cyclist asked for a smaller example that illustrated the issue, then your reply came back with something that is 4x4 but no associated vectors; just a set of points seemingly arbitrarily set to zero.
It's no wonder everybody is confused trying to keep up...
Stefano Russo
on 11 Jul 2023
Accepted Answer
More Answers (0)
Categories
Find more on General PDEs in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!