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)

 Accepted Answer

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 Comments

Pul
Pul on 1 Jul 2021
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
Pul
Pul on 2 Jul 2021
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
Pul
Pul on 2 Jul 2021
I get the same error!
Pul
Pul on 3 Jul 2021
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.

Sign in to comment.

More Answers (2)

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

6 Comments

Pul
Pul on 1 Jul 2021
Edited: Pul on 1 Jul 2021
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));
Pul
Pul on 1 Jul 2021
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.
David Hill
David Hill on 1 Jul 2021
Edited: David Hill on 1 Jul 2021
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
Pul
Pul on 2 Jul 2021
Even If I use stacked plot, I don't have years on the x-axis.

Sign in to comment.

Pul
Pul on 2 Jul 2021

0 votes

I get this error if I try in that way.

4 Comments

use the .mat file which you have attached in this thread
Pul
Pul on 2 Jul 2021
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') %
Pul
Pul on 3 Jul 2021
Thank you!

Sign in to comment.

Categories

Asked:

Pul
on 1 Jul 2021

Commented:

Pul
on 3 Jul 2021

Community Treasure Hunt

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

Start Hunting!