how to use self-defined function to fill matrix without loop?

1 view (last 30 days)
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
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
D_James
D_James on 24 Apr 2015
i and j representing the position of w matrix, i is from 1 to 6 and j is from 1 to 4, w is 6*4 matrix. Yes, myfunc is passing N(j) and M(1:i+1,:) to find r So totally I want to use myfunc to fill the matrix w depending on i and j

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB 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!