- 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.
- 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.
How can I solve this little error?
1 回表示 (過去 30 日間)
古いコメントを表示
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');
hold on
plot(datetime(DATIECMmensili.Year,1,1),(DATIECMmensili.Month,1,1),DATIECMmensili.SMB_mp_mm,'m-*', 'DisplayName','MAR');
legend('Location','best')
hold on
0 件のコメント
回答 (1 件)
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:
... 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
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');
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!