Can any one help me on this

1 vue (au cours des 30 derniers jours)
behailu woldesemayet
behailu woldesemayet le 21 Avr 2019
s = load('pvev.mat');
pvev = s.pvev;
T = pvev{:,1};
PV = pvev{:,2};
ST = pvev{:,3};
EV = pvev{:,4};
for T = pvev{:,1}
if((PV > ST) & (PV > EV))
m = PV;
plot(T,m,'r','linewidth',2);
hold on
elseif((ST > PV) & (ST > EV))
m = ST;
plot(T,m,'g','linewidth',2);
elseif((EV > ST) & (EV > PV))
m = EV;
plot(T,m,'b','linewidth',2);
hold off;
grid on;
end
end
it says 'Operands to the || and && operators must be convertible to logical scalar values.
  1 commentaire
Walter Roberson
Walter Roberson le 21 Avr 2019
Please show the complete error message.
Also, you appear to be plotting at a number of individual time points. When you use plot() then it only creates lines when you ask it to plot() two or more adjacent finite points in a single call to plot(). You should specify a marker in your plot() calls to be sure of seeing output for individual points.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 22 Avr 2019
Code is attached. I had to guess about what you were trying to do.
One of your cases leaves m undefined. That case occurs for your first point, time 0.
Your existing code implied that you would prefer to use different colors of line for the different segments. I choose to use different colors of markers instead. Using different colors of line is more work, and you need to define how to handle the transition between two points each of which have a clearly defined color but the two are different colors.
  2 commentaires
Walter Roberson
Walter Roberson le 24 Avr 2019
Revised version to draw the colored lines is attached.
behailu woldesemayet
behailu woldesemayet le 24 Avr 2019
It works well
thanks

Connectez-vous pour commenter.

Plus de réponses (3)

behailu woldesemayet
behailu woldesemayet le 21 Avr 2019
Operands to the || and && operators must be convertible to logical scalar values.
Error in solarpv (line 8)
if((PV > ST) && (PV > EV))
here is the full error message

behailu woldesemayet
behailu woldesemayet le 22 Avr 2019
Its Right but I want to change the color of the line to be visible.
thanks
  2 commentaires
Walter Roberson
Walter Roberson le 22 Avr 2019
What line color do you want to show up when one point is one of the cases, but the next point is a different one of the cases?
behailu woldesemayet
behailu woldesemayet le 22 Avr 2019
for the first case, red the second blue and the third green.

Connectez-vous pour commenter.


behailu woldesemayet
behailu woldesemayet le 22 Avr 2019
for the first case, red the second blue and the third green.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by