Unable to resolve the name Error

The error I keep recieving is as follows:
Unable to resolve the name 'triangle2.X.Data'.
Error in lab3 (line 7)
tt2 = triangle2.X.Data-1;
The code I have is as follows:
load triangle2.mat
%Triangular Pulse with 2V
tt2 = triangle2.X.Data-1;
ut2 = triangle2.Y(2).Data;
yt2 = triangle2.Y(1).Data;
offset = mean(yt2(1:9000));
yt2 = yt2 - offset;
I'm not sure what is causing this issue since I have not encountered it in previous versions when I ran similar code. I added a path to the folder containing the data as well, but I still recieve the same error. Thanks for any help!

3 件のコメント

Dyuman Joshi
Dyuman Joshi 2024 年 2 月 13 日
Please share the triangle2.mat file. Use the paperclip button to attach.
Grace
Grace 2024 年 2 月 13 日
Here is the file
Les Beckham
Les Beckham 2024 年 2 月 13 日
That file does not contain a variable called triangle2, or X or Y, for that matter.
whos -file triangle2.mat
Name Size Bytes Class Attributes exp1_014_mat_saving1 1x1 2650104 struct

サインインしてコメントする。

 採用された回答

Voss
Voss 2024 年 2 月 13 日

0 投票

This mat file contains one variable (called "exp1_014_mat_saving1"):
S = load('triangle2.mat')
S = struct with fields:
exp1_014_mat_saving1: [1×1 struct]
which is a struct with fields Info, X, Y, and Description:
S.exp1_014_mat_saving1
ans = struct with fields:
Info: [1×1 struct] X: [1×1 struct] Y: [1×2 struct] Description: [1×1 struct]
If you want that variable to be called "triangle2" so you can run your code without modification, you can make a new variable called "triangle2" in your code and assign it the value of "exp1_014_mat_saving1" from the mat file:
triangle2 = load('triangle2.mat').exp1_014_mat_saving1
triangle2 = struct with fields:
Info: [1×1 struct] X: [1×1 struct] Y: [1×2 struct] Description: [1×1 struct]
then the rest of your code runs without error:
%Triangular Pulse with 2V
tt2 = triangle2.X.Data-1;
ut2 = triangle2.Y(2).Data;
yt2 = triangle2.Y(1).Data;
offset = mean(yt2(1:9000));
yt2 = yt2 - offset;

2 件のコメント

Grace
Grace 2024 年 2 月 13 日
Thank you so much! I got the data from a partner, didn't realize that she renamed it after taking the data, so it had a different name.
Voss
Voss 2024 年 2 月 13 日
You're welcome!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

製品

リリース

R2023b

タグ

質問済み:

2024 年 2 月 13 日

コメント済み:

2024 年 2 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by