how to use self-defined function to fill matrix without loop?
1 view (last 30 days)
Show older comments
Hi,
I have an matrix M = randi(10,7,5)
M = randi(10,7,5);
N = randi(5,1,4);
function r = myfunc(x,y)...and get r is a number
I want to find out a way to fill the matrix W:
w = zeros(6,4)
w(i,j)= myfunc(N(j),M(1:i+1,:));
Does anyone know how to solve it? Thanks a lot.
2 Comments
Image Analyst
on 24 Apr 2015
What are the value for i and j that you're passing in? And what does myfunc() do to x and y (or N(j) and M(1:i+1,:)) to produce r, which you are assigning to w(i,j)? How could we possibly know? Are you multiplying them? Dividing them? What???? It looks like myfunc() outputs a single scalar number, not an array - is that what you think too? Read this
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!