I am not getting a linear plot, how can I get a plot that consist all the data points?
2 views (last 30 days)
Show older comments
Manav Divekar
on 7 Jun 2022
Commented: Star Strider
on 7 Jun 2022
I want to plot from the excel sheet from table F1:I31 but the matlab is not taking all the data and plotting. the does not seem correct
dataset = xlsread('Problem1.xlsx','Sheet1','F1:I31');
x = dataset(:,2);
y = dataset(:,3);
z = dataset(:,4);
figure
plot(x,y,'r');
xlabel('time');
ylabel('displacement');
title('U1');
figure
plot(x,z);
xlabel('time');
ylabel('displacement');
title('U2');
0 Comments
Accepted Answer
Star Strider
on 7 Jun 2022
You are asking it to read 30 rows across 4 columns, and it is doing exactly that —
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1024315/Problem1.xlsx','Sheet',1, 'Range','F1:I31', 'VariableNamingRule','preserve')
dataset = table2array(T1);
x = dataset(:,2);
y = dataset(:,3);
z = dataset(:,4);
figure
plot(x,y,'r');
set(gca, 'YScale','log') % <— ADDED
xlabel('time');
ylabel('displacement');
title('U1');
figure
plot(x,z);
set(gca, 'YScale','log') % <— ADDED
xlabel('time');
ylabel('displacement');
title('U2');
To get a plot that appears to be linear, plot the logarithm of the dependent variable.
.
2 Comments
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!