Borrar filtros
Borrar filtros

The operation or expression '(' has no effect

1 visualización (últimos 30 días)
Sarbajit Basu
Sarbajit Basu el 1 de Abr. de 2021
Respondida: Walter Roberson el 1 de Abr. de 2021
Hello all,
I wrote this code to generate multiple sheets having different 5*5 matrices. Somehow, my array ends up empty.
BingoShtGen generates a 5*5 array.
clc
clear all;
numSheets=20;
BngoSt=zeros(6,5,20);
for i=1:numSheets
BngoSt(1,1,i)=701;
BngoSt(1,2,i)=702;
BngoSt(1,3,i)=703;
BngoSt(1,4,i)=704;
BngoSt(1,5,i)=705;
end
for i=1:numSheets
BingoShtGen
bSt;
for iC=2:6
for jC=1:5
BngoSt(iC,jC,i)=bSt(iC-1,jC);
bSt(iC-1,jC);
BngoSt(iC,jC,i);
end
end
BngoSt(:,:,i);
tt=isempty(BngoSt);
bSt
tt
44;
end
tt=isempty(BngoSt);
tt;
  1 comentario
Rik
Rik el 1 de Abr. de 2021
If you have trouble with Matlab basics you may consider doing the Onramp tutorial (which is provided for free by Mathworks).
Unless BingoShtGen is a script, you aren't actually doing anything with the output. Also, unless bSt is a function, the second line in the inner loop doesn't do anything.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Abr. de 2021
We cannot tell whether bSt is a function or a variable. If it is a function then you call it once with two parameters and once with no parameters. If it is an anonymous function then you call it once with two parameters but another time just ask to display the formula. If it is a variable then you do not initialize it.
This is important because if you are initializing it inside a script BingoShtGen then current versions of MATLAB may not know that it is being created inside the script. If you are writing into it inside the script, then at some point before you call BingoShtGen you need to assign something to bSt in order for MATLAB to recognize that it is intended to be a variable (that might be changed inside a script.)

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by