I am not getting a linear plot, how can I get a plot that consist all the data points?

2 views (last 30 days)
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');

Accepted Answer

Star Strider
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')
T1 = 30×4 table
Time Step Number counter Time(t+deltat) U1 at (t+delta) U2 at (t+delta) ________________________ ______________ _______________ _______________ 1 21 2205 0 2 42 7.7792e+06 -1.4586e+06 3 63 2.9364e+10 -6.4312e+09 4 84 1.1217e+14 -2.5106e+13 5 105 4.2811e+17 -9.6175e+16 6 126 1.6364e+21 -3.6777e+20 7 147 6.2694e+24 -1.4087e+24 8 168 2.3973e+28 -5.3883e+27 9 189 9.1754e+31 -2.0619e+31 10 210 3.5094e+35 -7.8853e+34 11 231 1.342e+39 -3.0161e+38 12 252 5.1243e+42 -1.1522e+42 13 273 1.9574e+46 -4.3988e+45 14 294 7.493e+49 -1.6837e+49 15 315 2.8632e+53 -6.433e+52 16 336 1.0935e+57 -2.4577e+56
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.
.

More Answers (0)

Categories

Find more on Data Distribution Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!