필터 지우기
필터 지우기

how to delete elements in the matlab array by overcoming the Unable error to delete elements from this array because dimension 3 has fixed size.

조회 수: 6 (최근 30일)
hello, I have a 3D matrix array of 1x1x10001 and I want to delete the first array so I use the codingan below but I get an error like this
Unable error to delete elements from this array because dimension 3 has fixed size.
if anyone can help me how to solve this error and I can delete the first array, thank you very much I really hope the help of good people.
function y = fcn (u)
u(:,:,1) = [];
end
  댓글 수: 2
Naufal Arfani
Naufal Arfani 2021년 1월 5일
from what I noticed in squeeze mathworks, I think it's just to change the 3D matrix to 2D Matrix or Vector then how do I use it and be able to remove the first array as I want, is it possible you can give an example code please from my problem @Ruger28

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

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2021년 1월 5일
In your function y will not be set. You only try to remove one element from the input, that's wasting time. When I run this at the command-line prompt:
q = randn(1,1,12);
q(:,:,1) = [];
everything works fine.
HTH
  댓글 수: 2
Naufal Arfani
Naufal Arfani 2021년 1월 5일
편집: Naufal Arfani 2021년 1월 5일
thanks for entering so do I have to use the code like below? because I'm using a 3D matrix of 1x1x10001 @Bjorn Gustavsson or how do I set y so as not to waste time
function y = fcn (u)
u = randn(1,1,10001);
u(:,:,1) = [];
end
Bjorn Gustavsson
Bjorn Gustavsson 2021년 1월 5일
In the function you will have to assign something to the output variable y. Otherwise matlab will not know what to put into y, should it be exp(1) that's calculated? only the first component of u?, the sum of all components of u? Otherwise your function will return an error or a warning that y is not assigned in fcn (forgotten the exact message). This you do something like this:
function y = fcn(u)
u = randn(1,1,1001);
u(:,:,1) = [];
y = u;
end

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by