Undefined function or method 'mrdivide'

I am writing a code in matlab GUI and using uitable... Code in which error is there is given below
data=get(handles.uitable1,'data');
A(:,1)=data(:,2);
B(:,1)=(0.56*0.65)/A(:,1);
Error is undefined function or method 'mrdivide' Can anyone plz help me to fix this issue ?

댓글 수: 2

Stephen23
Stephen23 2018년 4월 2일
편집: Stephen23 2018년 4월 2일
The uitable data field can by a numeric, logical, or cell array. Possibly you have a cell array, in which case numeric operations are not defined for it. Solution: use a numeric array.
Gaurav
Gaurav 2018년 4월 2일
Being new to matlab.... I dont know from where i can choose whether it is a cell array or numeric array.... or any other array type .. Where can i select thpe of array in gui Thnx in advance

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

답변 (2개)

Image Analyst
Image Analyst 2018년 4월 2일
편집: Image Analyst 2018년 4월 2일

0 개 추천

Try doing an element by element divide with dot slash, and see if that fixes it:
whos A
B(:, 1) = (0.56 * 0.65) ./ A(:, 1); % Note: ./ NOT just simply /
If B is not defined as a 2-D array in advance, then you can get rid of the (:,1) and simply have
B = (0.56 * 0.65) ./ A(:, 1); % Note: ./ NOT just simply /
Steven Lord
Steven Lord 2018년 4월 2일

0 개 추천

I think Stephen's suspicion that A is a cell array is correct. To confirm this, add this line immediately after the line where you define A then run your code.
disp(class(A))
If this displays the word "cell", A is a cell array. If a regular numeric array is a walnut meat, a cell array containing numeric arrays is a walnut shell. You need to crack it open to get at the meat inside. You do that using curly brace indexing.
A = {1, 2:3, [4 5; 6 7]}
B = A(2)
C = A{2}
whos A B C
In that example, A and B are cell arrays. C is the contents of the second cell of the cell array A and so is a double array. Your code currently operates on B, but you want it to operate on C.

댓글 수: 4

Gaurav
Gaurav 2018년 4월 2일
Yes....u r right... All the data is in the form of array.... Now the problem is even if i have used curly brackets and done all the things proparly for matrix manipulations....(mrdivide error is eliminated now.)...but i still have problem for calculations as uitable is storing every single digit as a separate element in matrix..... Is there any way so that i can directly convert uitable data array in simple matrix form???
Walter Roberson
Walter Roberson 2018년 4월 2일
If every digit is stored separately then it is likely stored as a character vector. The single easiest way to prevent this is to initialize the Data property of the uitable as numeric such as zeros() of appropriate size.
Image Analyst
Image Analyst 2018년 4월 2일
You forgot to show the results of the "whos A" command, like I had in my code. Please do so.
There are arrays, and cell arrays (a special type of array). When you say "All the data is in the form of array" I do not know what you're talking about. Is A a double array? A cell array? A cell array that contains an array inside each cell?
Please read the FAQ on cell arrays before replying: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F
Gaurav
Gaurav 2018년 4월 3일
Thanx everyone... for your help... i have initiated array as a zeros() and it also works perfectly....

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

카테고리

도움말 센터File Exchange에서 Programming에 대해 자세히 알아보기

제품

태그

질문:

2018년 4월 2일

댓글:

2018년 4월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by