Readonly: Operands to the || and && operators must be convertable to logical scalar values. is eqal3, 153

1 vue (au cours des 30 derniers jours)
error.png
Hi, Can any one have idea, how to resolve it. This is freqently appearing when I run my code.

Réponses (1)

Aravind Ravikumar
Aravind Ravikumar le 20 Juin 2019
You get this when one or both operands are arrays. E.g.,
>> [1 2 3] && [4 5 6]
Operands to the || and && operators must be convertible to logical scalar values.
Check the two expressions or variables you are using for the || or && operation. You are using them as scalars but they are not.
You could refer to this link too.
  2 commentaires
Hafeezullah Amin
Hafeezullah Amin le 20 Juin 2019
This is my code: I have loaded a file name S(1).mat, which contained many matices of different sizes. I want to extract matrix of size (129x10000 or above). I have loaded EEGLAB, from where I am using their function pop_importdata(). I have attached the print screen of my workspace which the loaded data. error 2.png
********************************************************
clc;
for S =1:100
load(['C:\Users\....\S (' int2str(S) ').mat']);% data
z_c = whos;
sam = 0;
for k = 1:length(z_c)
if z_c(k,1).size(1,1) == 129 && z_c(k,1).size(1,2)>10000
name = z_c(k,1).name;
end
if z_c(k,1).size(1,1) == 129 && z_c(k,1).size(1,2)<10000 && z_c(k,1).size(1,2)>1
name1(k,:) = z_c(k,1).name;
sam = [sam + length(eval(name1(k,:)))];
end
end
epo = str2num(name(length(name)));
addpath (genpath('C:\Users\...\MATLAB\eeglabdevelopers')) % EEG lab folder
EEG = pop_importdata('data',name,'dataformat','matlab','srate',250);
eeg = [EEG.data(1:129,:)];
% new folder for cleaned file
name1 = (['C:\Users\...\EEG\S (' int2str(S) ').mat']);
save(name1,'eeg')
clear all;
end
*********************************************************************
Aravind Ravikumar
Aravind Ravikumar le 20 Juin 2019
The only way I can imagine the error being genereted is cause of z_c(k,1).size(1,x) not being a scalar. Could you maybe try logging that before the if statements? Also, could you try using z_c(k).size(x) instead?

Connectez-vous pour commenter.

Catégories

En savoir plus sur EEG/MEG/ECoG dans Help Center et File Exchange

Tags

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by