HOW CAN I PLOT THIS?

Hello, I'm not able to plot this even if I converted the data I need in table.
Could anyone kindly help me please?
Thank you!
clear all
close all
load('GIULIA_MMEQ1.mat');
A=table2array(GIULIAMMEQ1(:,2));
B=str2double(A);
giulia_MM_EQ_NEW= B * 0.35 * 10;
C=array2table(GIULIAMMEQ1);
stackedplot(GIULIAMMEQ1.Dec1997,C)

 采纳的回答

Please check and confirm the correction
clear all
close all
clc
load('EXAMPLE.mat');
A=GIULIAMMEQ1.Var4%table2array(EXAMPLE(:,2)); EXAMPLE.mat contains GIULIAMMEQ1 instead of table EXAMPLE
B=str2double(A);
NEW= B * 50 * 20;
C=GIULIAMMEQ1.Var4%array2table(EXAMPLE);% TABLE EXAMPLE MISSING
% plot(EXAMPLE.Dec1997,C)
stackedplot(GIULIAMMEQ1)

9 个评论

I can't see the plot.
stored date format is not in order required some modification and conversion
load('EXAMPLE.mat');
A=GIULIAMMEQ1.Var4%table2array(EXAMPLE(:,2));
B=str2double(A);
NEW= B * 50 * 20;
C=GIULIAMMEQ1.Dec1997%array2table(EXAMPLE);%
for ii=1:length(C)
c_store=convertStringsToChars(C(ii)); %convert string to char
C(ii)=c_store(1:end-2); % remove ';' from the end of date and time
end
C=datetime(C,'InputFormat','dd MM yyyy'); %converst to datetime format
stackedplot(C,NEW) %level as your choice
I get this error if I try in that way!
I am not getting the error
please check your EXAMPLE.mat file
clear all
close all
clc
load('EXAMPLE.mat');
A=GIULIAMMEQ1.Var4;%table2array(EXAMPLE(:,2));
B=str2double(A);
NEW= B * 50 * 20;
C=GIULIAMMEQ1.Dec1997;%array2table(EXAMPLE);%
C=replace(C,"';","");
C=datetime(C,'InputFormat','dd MM yyyy'); %converst to datetime format
stackedplot(C,NEW) %level as your choice
More simplified code removing for loop
I get the same error!
I found out the error: I have to put 'dd MMM yyyy'.
Last quick question: how can I delete "Column 1" that appear in the y-axis and giving it another label?
Because I get this error:
Thank you.

请先登录,再进行评论。

更多回答(2 个)

load('EXAMPLE.mat');
m=table2array(GIULIAMMEQ1);
d=datenum(m(:,1));
v=str2double(m(:,2));
idx=~isnan(v);
plot(d(idx),v(idx));

6 个评论

Pul
Pul 2021-7-1
编辑:Pul 2021-7-1
Thank you!
But I'm not able to understand where the multiplication is.
I should have years on the x-axis.
Converted time string to datenum value for easy plotting.
load('EXAMPLE.mat');
m=table2array(GIULIAMMEQ1);
d=datenum(m(:,1));
v=3.5*str2double(m(:,2));%figured you could figure out where you wanted to multiply
idx=~isnan(v);
plot(d(idx),v(idx));
Okay, thank you.
But on the x-axis, I still have numbers and not data time(column 1 of "GIULIAMMEQ1"), as you can see in the attached image.
look at datenum()
load('EXAMPLE.mat');
m=table2array(GIULIAMMEQ1);
d=datenum(m(:,1));
v=3.5*str2double(m(:,2));%figured you could figure out where you wanted to multiply
idx=~isnan(v);
plot(d(idx)-730088,v(idx));%substract the first date to get days on horizontal
Use stackedplot instead of plot for the correction on x axis leveling
Even If I use stacked plot, I don't have years on the x-axis.

请先登录,再进行评论。

Pul
Pul 2021-7-2

0 个投票

I get this error if I try in that way.

4 个评论

use the .mat file which you have attached in this thread
I tried with that but the error still occurs; I don't know where the problem is.
Thank you for your patience.
T=table(C,NEW,'Variablenames',{'Year' 'Value'}); %Put label
stackedplot(T,'XVariable','Year') %
Thank you!

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Timetables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by