Filter löschen
Filter löschen

Running a function of 2 variables

1 Ansicht (letzte 30 Tage)
Hayden
Hayden am 17 Okt. 2014
Beantwortet: Mohammad Abouali am 17 Okt. 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 Kommentar
Guillaume
Guillaume am 17 Okt. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Mohammad Abouali
Mohammad Abouali am 17 Okt. 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.

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays 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