How can I solve this little error?

2 次查看(过去 30 天)
Pul
Pul 2021-8-16
评论: Pul 2021-8-16
Hello everyone,
I get this little error while plotting (plot (datetimeDATIMAR and datetimeDATIECMWF).
How can I solve it?
Thank you.
clear all
close all
load('giulia_TT.mat')
giulia_monthly=retime(giulia_TT,'monthly','mean');
load('giulia_monthly_DELTA');
E = giuliamensile.Height
NEW_6=E *0.35 *10;
% c=giuliamensile{:,1};
% c=datetime(c,'InputFormat','MM-yyyy');
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%FILTERING
%ag2000-sept2000
for i =33:34
if NEW_6(i,1)>=150
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%sept2001-oct2001
for i =46:47
if NEW_6(i,1)>=200
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%sept2005
for i =94:94
if NEW_6(i,1)>=300
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%sept2008-Oct2008
for i =130:131
if NEW_6(i,1)>=230
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%sept2007-Nov2007
for i =118:120
if NEW_6(i,1)>=325
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%RIALZARE
%dic2007-nov2013
for i=121:192
NEW_6(i,1)=NEW_6(i,1)+171.68
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
%filter
%giugno 2009-aug 2009
for i =139:141
if NEW_6(i,1)>=500
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%luglio 2011-aug 2011
for i =164:165
if NEW_6(i,1)>=500
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%RIALZARE
%jan 2014
for i=194:254
NEW_6(i,1)=NEW_6(i,1)+584.0204
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
%FILTERING
%AUG2016-SEP2016
for i =225:226
if NEW_6(i,1)>=1000
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
%JUN2015-SEP2015
for i =211:214
if NEW_6(i,1)>=800
NEW_6(i)=NaN;
end
end
plot(giulia_monthly.Time,NEW_6(:,1),'g-^' ,'MarkerEdgeColor','k','MarkerFaceColor','g') ;
hold on
load('DATI_ECM_MENSILI');
load('DATI_MAR_MENSILI');
plot(datetime(DATIMARmensili.Year(20:end,1),1,1),(DATIMARmensili.Month(20:end,1),1,1) DATIMARmensili.SMB_mpmm(20:end,1),'--co', 'MarkerEdgeColor','k','MarkerFaceColor','c', 'DisplayName','ECMWF');
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.

Error in connector.internal.fevalMatlab

Error in connector.internal.fevalJSON
hold on
plot(datetime(DATIECMmensili.Year,1,1),(DATIECMmensili.Month,1,1),DATIECMmensili.SMB_mp_mm,'m-*', 'DisplayName','MAR');
legend('Location','best')
hold on

回答(1 个)

Walter Roberson
Walter Roberson 2021-8-16
编辑:Walter Roberson 2021-8-16
plot(datetime(DATIMARmensili.Year(20:end,1),1,1),(DATIMARmensili.Month(20:end,1),1,1) DATIMARmensili.SMB_mpmm(20:end,1),'--co', 'MarkerEdgeColor','k','MarkerFaceColor','c', 'DisplayName','ECMWF');
^
At the marked place, you have just finished the second parameter (DATIMARmensili.Month(20:end,1),1,1) and then you have a space and then you have an expression. You do not have any operator between the () expression and the following DATIMARmensili expression.
In MATLAB, the cases in which it is permitted to have two expressions separated by a space, with no operator between them, are:
  1. You are at the first bracket nesting level within a [] list-building expression. For example, [1 a+2 3] is valid. In this case, the spaces are interpreted as-if you had a comma there, equivalent to [1, a+2, 3] in this example.
  2. You are at the first bracket nesting level within a {} cell-building expression. For example, {1 a+2 3} is valid. In this case, the spaces are interpreted as-if you had a comma there, equivalent to {1, a+2, 3} in this example.
... And that is it. Every other case in which you have two expressions in a row without an operator between them, is an error in MATLAB.
MATLAB has absolutely no implied multiplication. Not anywhere.
That said... your line is basically a mistake in nearly every component. I showed you a more correct line at https://www.mathworks.com/matlabcentral/answers/897572-how-to-plot-this-line#answer_766657
  5 个评论
Walter Roberson
Walter Roberson 2021-8-16
编辑:Walter Roberson 2021-8-16
plot(datetime(DATIECMWFmensili.Year(20:end), DATIECMWFmensili.Month(20:end), 1), DATIECMWFmensili.SMB_mpmm, 'm-*', 'DisplayName','ECMWF');
Pul
Pul 2021-8-16
Thanks, but you should have added (20:end) at DATIECMWFmensili.SMB_mpmm.
In this way, it works.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by