How to Fix the “Dot indexing not supported for variables of this ty... (2024)

91 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

Aedy Vader am 5 Okt. 2023

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab

  • Verknüpfen

    Direkter Link zu dieser Frage

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab

Bearbeitet: Walter Roberson am 9 Okt. 2023

Akzeptierte Antwort: dpb

I am writing a code and i've tried to run it. However, it shows me an error saying "Dot indexing is not supported for variables of this type".

Dot indexing is not supported for variables of this type.

Error in SDE (line 38)

dataset = dataset.Train;

Any kind of help will be appreciated. Thank you.

dataset = load(['/Users/zachary/Desktop/MatlabCode/SDE-master/train/',p_name]);

dataset = dataset.Train;

feat = dataset(:,1:end-1);

labels = dataset(:,end);

4 Kommentare

2 ältere Kommentare anzeigen2 ältere Kommentare ausblenden

Fabio Freschi am 5 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912189

dataset is not a struct? difficult to say without the file you are loading

Dyuman Joshi am 5 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912244

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912244

Bearbeitet: Dyuman Joshi am 5 Okt. 2023

It seems the variable dataset is not a struct nor a table, thus using dot indexing gives an error.

It would be helpful if you can attach the file.

Aedy Vader am 5 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912279

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912279

  • QSARbiodegradation.txt

This is the file that you've asked for.

Dyuman Joshi am 5 Okt. 2023

Direkter Link zu diesem Kommentar

https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912319

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#comment_2912319

Bearbeitet: Dyuman Joshi am 5 Okt. 2023

This is just a numeric text file. No headers or anything, just plain numbers. The output will be a numeric array when you read the data in the file with load.

Additionally, the input to load() does not contain the filename (including the extension). Why does it not?

And what are you trying to obtain from the data?

(Also, Are you related to Darth Vader? :P)

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Akzeptierte Antwort

dpb am 5 Okt. 2023

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#answer_1327079

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#answer_1327079

Bearbeitet: Walter Roberson am 9 Okt. 2023

  • QSARbiodegradation.txt

That's just a plain text file; use readmatrix to bring it in as an array...

% first read as text to be certain of file structure -- lines are wrapped in browser

l=readlines('QSARbiodegradation.txt');

l(1:5)

ans = 5×1 string array

" 5.3030000e+000 4.0516000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.0000000e+000 0.0000000e+000 2.6100000e+001 4.0000000e+000 3.0000000e+000 0.0000000e+000 0.0000000e+000 3.0100000e+000 1.3920000e+000 1.0053000e+001 9.0000000e+000 1.0070000e+000 1.1540000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.0790000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 2.2360000e+000 4.4000000e-002 0.0000000e+000 0.0000000e+000 1.1640000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 3.0000000e+000 3.3200000e+000 3.0280000e+000 0.0000000e+000 7.4530000e+000 0.0000000e+000 0.0000000e+000 2.0000000e+000" " 4.4990000e+000 2.9058000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.0000000e+000 4.3800000e+001 1.0000000e+000 1.0000000e+000 0.0000000e+000 0.0000000e+000 2.9900000e+000 1.1250000e+000 9.3110000e+000 2.0000000e+000 9.9100000e-001 1.1170000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.2430000e+000 1.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 2.1360000e+000 4.4000000e-002 0.0000000e+000 0.0000000e+000 1.4810000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.0000000e+000 3.5560000e+000 2.3960000e+000 0.0000000e+000 7.8450000e+000 0.0000000e+000 0.0000000e+000 1.0000000e+000" " 5.0130000e+000 1.8267000e+000 2.0000000e+000 1.0000000e+000 1.6000000e+001 0.0000000e+000 7.0000000e+000 4.2400000e+001 2.0000000e+000 5.0000000e+000 1.4000000e+001 -1.1230000e+000 4.6920000e+000 1.5410000e+000 1.1371000e+001 5.0000000e+000 1.0190000e+000 1.1210000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.2770000e+000 5.0000000e+000 0.0000000e+000 1.0000000e+000 0.0000000e+000 2.4150000e+000 0.0000000e+000 0.0000000e+000 3.5613000e+001 4.3740000e+000 0.0000000e+000 4.0000000e+000 1.3000000e+001 1.0000000e+000 4.3040000e+000 2.4440000e+000 5.0000000e+000 9.9560000e+000 0.0000000e+000 1.0000000e+000 2.0000000e+000" " 4.9710000e+000 3.0393000e+000 0.0000000e+000 0.0000000e+000 2.0000000e+000 0.0000000e+000 2.0000000e+000 3.8700000e+001 3.0000000e+000 1.0000000e+000 2.0000000e+000 1.2400000e-001 3.5090000e+000 1.7330000e+000 1.0236000e+001 4.0000000e+000 9.8400000e-001 1.1300000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.2510000e+000 1.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 2.3050000e+000 1.0000000e-003 0.0000000e+000 1.1885000e+001 2.5850000e+000 0.0000000e+000 0.0000000e+000 3.0000000e+000 0.0000000e+000 3.7250000e+000 2.2140000e+000 1.0000000e+000 8.4400000e+000 0.0000000e+000 0.0000000e+000 2.0000000e+000" " 5.3610000e+000 1.8900000e+000 0.0000000e+000 0.0000000e+000 2.0000000e+000 1.0000000e+000 0.0000000e+000 2.8900000e+001 2.0000000e+000 4.0000000e+000 2.0000000e+000 0.0000000e+000 3.7640000e+000 1.5910000e+000 1.0691000e+001 1.6000000e+001 1.0030000e+000 1.1510000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 1.1320000e+000 2.0000000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 2.4070000e+000 0.0000000e+000 0.0000000e+000 0.0000000e+000 3.2610000e+000 0.0000000e+000 0.0000000e+000 2.0000000e+000 4.0000000e+000 3.4950000e+000 2.1540000e+000 2.0000000e+000 8.3250000e+000 0.0000000e+000 0.0000000e+000 2.0000000e+000"

And, indeed, that is so..

data=readmatrix('QSARbiodegradation.txt'); % read the array

data(1:5,:)

ans = 5×42

5.3030 4.0516 0 0 0 1.0000 0 26.1000 4.0000 3.0000 0 0 3.0100 1.3920 10.0530 9.0000 1.0070 1.1540 0 0 0 1.0790 0 0 0 0 2.2360 0.0440 0 0 4.4990 2.9058 0 0 0 0 1.0000 43.8000 1.0000 1.0000 0 0 2.9900 1.1250 9.3110 2.0000 0.9910 1.1170 0 0 0 1.2430 1.0000 0 0 0 2.1360 0.0440 0 0 5.0130 1.8267 2.0000 1.0000 16.0000 0 7.0000 42.4000 2.0000 5.0000 14.0000 -1.1230 4.6920 1.5410 11.3710 5.0000 1.0190 1.1210 0 0 0 1.2770 5.0000 0 1.0000 0 2.4150 0 0 35.6130 4.9710 3.0393 0 0 2.0000 0 2.0000 38.7000 3.0000 1.0000 2.0000 0.1240 3.5090 1.7330 10.2360 4.0000 0.9840 1.1300 0 0 0 1.2510 1.0000 0 0 0 2.3050 0.0010 0 11.8850 5.3610 1.8900 0 0 2.0000 1.0000 0 28.9000 2.0000 4.0000 2.0000 0 3.7640 1.5910 10.6910 16.0000 1.0030 1.1510 0 0 0 1.1320 2.0000 0 0 0 2.4070 0 0 0

whos data

Name Size Bytes Class Attributes data 739x42 248304 double

No "dot" referencing needed (or allowed). If there are meaningful variable names for each column, then you could use those and either use array2table and assign those or go directly to the table with readtable. However, with 42 columns, it's probably not a particularly convenient data set to use named column variables...

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson am 5 Okt. 2023

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#answer_1327069

  • Verknüpfen

    Direkter Link zu dieser Antwort

    https://de.mathworks.com/matlabcentral/answers/2029829-how-to-fix-the-dot-indexing-not-supported-for-variables-of-this-type-error-in-matlab#answer_1327069

load() of a .txt file never results in a struct or object so you cannot use dot indexing with it. (well, except if you use the -mat option and the .txt file happened to be mat file format)

load() of a .mat file stored to a file results in a struct -- but not of a .txt

importdata() of a .txt file results in a pure numeric matrix if the txt file has no text headers. But if it has text headers then importdata() can return a struct with a few different possible fields (that are not always going to be present.) Because of this variability in what data type impordata() can return, I recommend against using importdata()

0 Kommentare

-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABData Import and AnalysisData Import and ExportStandard File FormatsText Files

Mehr zu Text Files finden Sie in Help Center und File Exchange

Tags

  • indexing
  • data import

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by How to Fix the “Dot indexing not supported for variables of this ty... (8)

How to Fix the “Dot indexing not supported for variables of this ty... (9)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asien-Pazifik

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Kontakt zu Ihrer lokalen Niederlassung

How to Fix the “Dot indexing not supported for variables of this ty... (2024)
Top Articles
Latest Posts
Article information

Author: The Hon. Margery Christiansen

Last Updated:

Views: 6301

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: The Hon. Margery Christiansen

Birthday: 2000-07-07

Address: 5050 Breitenberg Knoll, New Robert, MI 45409

Phone: +2556892639372

Job: Investor Mining Engineer

Hobby: Sketching, Cosplaying, Glassblowing, Genealogy, Crocheting, Archery, Skateboarding

Introduction: My name is The Hon. Margery Christiansen, I am a bright, adorable, precious, inexpensive, gorgeous, comfortable, happy person who loves writing and wants to share my knowledge and understanding with you.