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 日間)
Mohammad irfan
Mohammad irfan 2019 年 4 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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 件のコメント
Torsten
Torsten 2019 年 4 月 24 日
編集済み: Torsten 2019 年 4 月 24 日
h=((s.*n.*c)./(1+(s.*n.*c)));
And dimensions of s, n and c must be the same.
Mohammad irfan
Mohammad irfan 2019 年 4 月 24 日
yes bro i already attach the file as you can see and the dimesion is same for those 3 variables as far as i know can u please check it out if u can do anything.

回答 (1 件)

Dennis
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 件のコメント
Mohammad irfan
Mohammad irfan 2019 年 4 月 25 日
編集済み: Mohammad irfan 2019 年 4 月 25 日
thank you so much dennis my error is gone but i still can't plot my graph i am getting this error
Error using plot
Error in color/linetype argument.
Error in matlabreport>pushbutton2_Callback (line 161)
plot(f,h)
please help me i need to submit my assignment
Walter Roberson
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!

Translated by