Filter löschen
Filter löschen

The operation or expression '(' has no effect

1 Ansicht (letzte 30 Tage)
Sarbajit Basu
Sarbajit Basu am 1 Apr. 2021
Beantwortet: Walter Roberson am 1 Apr. 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 Kommentar
Rik
Rik am 1 Apr. 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Apr. 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.)

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices 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!

Translated by