Info
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
i keep on getting this error even after changing my codes multiple times using .* and etc. it keep on showing that i have prob with my equation when there is no visible problem.
조회 수: 1 (최근 30일)
이전 댓글 표시
i keep on getting this error even after changing my codes multiple times using .* and etc. it keep on showing that i have prob with my equation when there is no visible problem.
Error using .*
Matrix dimensions must agree.
Error in matlabreport>pushbutton2_Callback (line 158)
h=((s.*n.*c)/(1+(s.*n.*c)));
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in matlabreport (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)matlabreport('pushbutton2_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
>>
댓글 수: 2
답변 (1개)
Dennis
2019년 4월 24일
Usually the error is straight forward and you can always check the size of your elements with (size) or using the debugger.
In your code it is obvious, that not all 3 variables have the same size (s is a vector with 1000001 elements and the n and c appear to be scalar, unless you somehow enter a vector with a million elements in an edit field).
Worth noting is that the multiplication of a vector with two scalars should work with (.*) or (*). However you converted one of your scalars in a string.
This should do the trick, but maybe consider storing c as number instead:
h=((s.*n.*str2double(c))/(1+(s.*n.*str2double(c))));
댓글 수: 2
Walter Roberson
2019년 4월 25일
That is odd. Could you put a breakpoint there and check class() of h and f and size() of them?
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!