What is wrong with this?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I need to be able to determine what my code is producing.
It yields:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159033/image.jpeg)
How do I look into the cells that are listed to get it to print out the results?
The code that produces this is:
function SQUARE = logipack( V)
% Find the size of the input matrix
[m,n] =size(V);
SQUARE = cell(m,1);
for r=1:m
for c=1:n % note here that I am using n and not m like in your code
% create an empty array
counter=0;
if V(r,c) > 0
counter = c;
end
if counter >=1
SQUARE{r,counter}=cell(counter);
end
end
end
end
This problem is described as:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/159034/image.jpeg)
%
2 Kommentare
Geoff Hayes
am 16 Dez. 2016
DJ - rather than posting duplicate questions, why not further the conversation at http://www.mathworks.com/matlabcentral/answers/317062-told-to-ask-a-new-question-why-won-t-this-work?
Akzeptierte Antwort
Weitere Antworten (1)
DJ V
am 16 Dez. 2016
2 Kommentare
Steven Lord
am 16 Dez. 2016
The assignment says the output should be a logical array. The output from your function is a cell array. A cell array could contain a logical array, but it is not itself a logical array.
C = {true false true};
isa(C, 'logical') % it is not a logical array
isa(C{1}, 'logical') % it contains a logical array
Siehe auch
Kategorien
Mehr zu Matrix Operations and Transformations 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!