필터 지우기
필터 지우기

Running a function of 2 variables

조회 수: 1 (최근 30일)
Hayden
Hayden 2014년 10월 17일
답변: Mohammad Abouali 2014년 10월 17일
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
Guillaume
Guillaume 2014년 10월 17일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Mohammad Abouali
Mohammad Abouali 2014년 10월 17일
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.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by