Prev: Save state of a GUI with IMROI object
Next: ask for help about the simulation result of power_wind_dfig.mdl
From: Frank Bieniek on 27 Mar 2010 23:21 ok so the question is Write a function named `m1' that works like the `ones' function. Be sure it works for either 1 input or 2. function [out1 out2] = m1(x,y); if nargin==1 I am really stuck on this this is all i got. Can anyone help me? I know its suppost to be in a nested loop and stuff.
From: Walter Roberson on 27 Mar 2010 23:44
Frank Bieniek wrote: > ok so the question is Write a function named `m1' that works like the > `ones' function. Be sure it works for either 1 input or 2. > > > > function [out1 out2] = m1(x,y); > if nargin==1 > > > I am really stuck on this this is all i got. Can anyone help me? I > know its suppost to be in a nested loop and stuff. Why use a nested loop? T = 1; if nargin==1 repmat(T,1:x,1:x) else repmat(T,1:x,1:y) end This isn't exactly correct from a point of view of all of the different options that ones() has, but it will get you started. Note: ones() also has a 3 argument calling syntax, and there is a two argument calling sequence that should be interpreted in terms of that third possible argument, so if you are required to handle the two argument version, then to be correct you need to be able to handle the implications of the third argument as well... |