constructing a particular "if statement"

Hi,
I have
[N,T,R]=xlsread(name);
R is a cell matrix
N is a double array
R(:,2) contains string variables and zeros.
R(:3) contains NaN and numbers
I want to construct the following "if statement"
if R(:,3) contains zeros OR (R(:,3) contains no zeros AND R(:,2) does not contain only zeros)
N=N
elseif R(:,3) does not contain zero AND R(:,3) contains only NaNs
N=[ zeros(size(R,1),1) N]
else
N=N
end
thanks
[EDITED, code formatted, Jan]

9 commentaires

Sabbas
Sabbas le 6 Juil 2012
Am i not explicit in my question? Please feel free to tell me
thanks
Jan
Jan le 6 Juil 2012
Please format your code properly. It is worth to explain the type of the used variables. E.g. R is a cell, correct? A small representative example of the data would be helpful also.
Jan
Jan le 6 Juil 2012
Modifié(e) : Jan le 6 Juil 2012
What does "R(:,2) contains zeros" exactly mean? A scalar 0 or an array, which contains 0 only? Same for "R(:, 3) contains numbers".
What is the purpose of "N=N"?! As far as I can see, only the ELSEIF matters, because N=N does not do anything.
R(:,2) and R(:,3) are respectively
'TOAR' [1.1021]
'WIEER' [1.0467]
[1x36 char] [0.9864]
[1x32 char] [0.7509]
[1x32 char] [0.9611]
'DR.ER' [1.4044]
[1x39 char] [1.3659]
[1x39 char] [1.4902]
[1x30 char] [ 0]
'SCHNEE' [2.8153]
[1x36 char] [2.6708]
[1x34 char] [2.9478]
[1x31 char] [3.5192]
'VOG ACK' [2.0153]
[1x35 char] [2.0153]
[ 0] [ 0]
[ 0] [ 0]
'PABEL' [1.8466]
[ NaN] [ NaN]
[ NaN] [ NaN]
I want to construct the following "if statement" (it is corrected)
if R(:,3) contains zeros OR (R(:,3) contains no zeros AND R(:,2) contains everthing-numbers, NaNs, zeros)
N remains unchanged
elseif R(:,3) contains everything apart from zeros AND R(:,2) contains only NaNs
N=[ zeros(size(R,1),1) N]
end
thanks
Sabbas
Sabbas le 6 Juil 2012
Any suggestions?
thanks in advance
Sabbas
Sabbas le 6 Juil 2012
can anyone help?
thanks
Sabbas
Sabbas le 6 Juil 2012
Any help?
thanks
Sabbas
Sabbas le 7 Juil 2012
could anyone help?
thanks
Jan
Jan le 7 Juil 2012
I asked you already to provide the required information, but you have posted a kind of list, which I cannot use as input for Matlab. The meaning of "R(:,2) and R(:,3) are respectively" is very obvious for you, but a puzzle for anybody, who is not involved in your problem.
In addition you did not answer my question about "N=N".
Instead of adding corrections as comment, it would be much more friendly to the readers of your question, to edit the original question.
Please answer questions for clarifications, post the input of your problem in valid Matlab syntax, such that it can be copied&pasted, add corrections by editing the question and mention any changes by an [EDITED] tip, and please do stop bumping your question repeatedly. When the readers have not been able to answer the question due to a well definition, they cannot offer an answer 3 hours later. Therefore the bumping is annoying.

Réponses (1)

John Petersen
John Petersen le 6 Juil 2012

0 votes

isnan(x) tests for NaNs (returns a 1 for each NaN, and a 0 otherwise)
(x==0) tests for 0s (returns a 1 for each 0, and 0 otherwise)

Cette question est clôturée.

Question posée :

le 6 Juil 2012

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by