Azzera filtri
Azzera filtri

Running a function of 2 variables

1 visualizzazione (ultimi 30 giorni)
Hayden
Hayden il 17 Ott 2014
Risposto: Mohammad Abouali il 17 Ott 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 Commento
Guillaume
Guillaume il 17 Ott 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.

Accedi per commentare.

Risposta accettata

Mohammad Abouali
Mohammad Abouali il 17 Ott 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.

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by