Borrar filtros
Borrar filtros

Running a function of 2 variables

1 visualización (últimos 30 días)
Hayden
Hayden el 17 de Oct. de 2014
Respondida: Mohammad Abouali el 17 de Oct. de 2014
I am having trouble running this command:
cr = [0:.1:1];
cr = logical(cr);
wn = [0:.1:1];
wn = logical(wn);
amp(cr,wn) = sqrt(1-2.*cr.*(1-cos(pi.*wn)).*(1-cr))
I get this error:
Subscripted assignment dimension mismatch.
Error in FundamentalsHW4 (line 6) amp(cr,wn) = sqrt(1-2.*cr.*(1-cos(pi.*wn)).*(1-cr))
Any help?
  1 comentario
Guillaume
Guillaume el 17 de Oct. de 2014
The best way for you to find what is wrong is to step through your code with the debugger.
Your code makes no sense, and you would have seen that immediately if you'd gone through the debugger. Why are you converting cr and wn to logical? Both of them end up as an array of 0 and 1 with only the first element as 0.
If you need more help, you would be better off explaining what you are trying to do rather than asking us to correct code that may not even be the solution to what you want.

Iniciar sesión para comentar.

Respuesta aceptada

Mohammad Abouali
Mohammad Abouali el 17 de Oct. de 2014
cr = [0:.1:1];
wn = [0:.1:1];
f=@(cr,wn) sqrt(1-2.*cr.*(1-cos(pi.*wn)).*(1-cr))
amp=bsxfun(f,cr',wn)
I think that's what you want to do.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by