how to plot table to line graph with dots ?

5 vues (au cours des 30 derniers jours)
Arif le 19 Fév 2024
Commenté : Dyuman Joshi le 19 Fév 2024
hi guys, i have data from the table as picture below. I want to make line graph from data table which X-axes as 'U1' and Y-axes as 'GlobalFx'.
how to plot ?
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Réponse acceptée

Star Strider le 19 Fév 2024
There are easier ways to import the table using detectImportOptions, however since it exists as posted, try this —
x = str2double(strrep(pushovertable.U1, ,',','.'))
y = str2double(strrep(pushovertable.GlobalFX,',','.'))
figure
plot(x, y, '.')
grid
.
.
1 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Dyuman Joshi le 19 Fév 2024
You could perform that operation on the whole table and then use indexing to plot directly from the table.

Connectez-vous pour commenter.

Plus de réponses (3)

Dyuman Joshi le 19 Fév 2024
Convert the data to double data type, and use indexing to plot the data (Reference for syntax - https://in.mathworks.com/help/matlab/ref/plot.html#d126e1185592)
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Image Analyst le 19 Fév 2024
Your numbers have commas in them instead of decimal points. That's probably why it reads them in as character arrays instead of doubles. What are your operating system regional settings? Can you change them so that it reads in the numbers as numbers?
Otherwise loop over those values using str2double to convert them to doubles.
strGlobalFX = pushovertable.GlobalFX(2:end);
strU1 = pushovertable.U1(2:end); % Skip missing first row
for row = 1 : numel(strGlobalFX)
str = strrep(strGlobalFX(row), ',', '.'); % Convert comma to decimal point.
GlobalFx(row) = str2double(str); % Convert to number
str = strrep(strGlobalFX(row), ',', '.'); % Convert comma to decimal point.
U1(row) = str2double(str); % Convert to number
end
plot(U1, GlobalFX, 'b-');
xlabel('U1')
ylabel('GlobalFx')
grid on;
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Fangjun Jiang le 19 Fév 2024
plot(pushovertable.("U1"),pushovertable.("GlobalFX"))
0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Catégories

En savoir plus sur Line Plots dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by