Vector inputs in functions

1 Ansicht (letzte 30 Tage)
Matthew Pearson
Matthew Pearson am 23 Sep. 2015
Beantwortet: Walter Roberson am 23 Sep. 2015
I need to put a vector input into a function and then use repmat to repeat each element a certain number of times. I have my input as repvec = (x,w), where x is the vector and w is the number of times to repeat it. I keep getting an error that says repvec is undefined. This is my code:
function vec = repvecR2(x,w)
n = length(x)
vec = repmat(w,1:n)
end

Antworten (1)

Walter Roberson
Walter Roberson am 23 Sep. 2015
You called your function repvecR2 but you are trying to invoke repvec without the R2

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by