- Everywhere in your code that your reference X1, use roi_signal_all instead, because that is the name of the stored variable.
- Before you run your code, load the MAT file, assign X1 = roi_signal_all, then re-save the MAT file so that it has a variable named X1.
How to give variable name to a Mat file?
1 次查看(过去 30 天)
显示 更早的评论
I have a mat file in which the data is of variable X1 in my program. I loaded the data but it's giving an error. Please help.
load ("X1.mat")
AddnumX1=10;%Num1er of additional data points in each time interval.
NX1=AddnumX1*length(X1); %Length of the reconstructed signal(the continuous signal);
RecX1=zeros([1,NX1]);
RateX1=zeros([1,NX1]);
n_x1=zeros([1,NX1]);
N_X1=zeros([1,length(X1)]);
zeroline_X1=zeros([1,NX1]);
index=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:NX1
if mod(i,AddnumX1)==1
index=index+1;
N_X1(index)=i;
end
n_x1(i)=i;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:NX1
RecX1(i)=0;
RateX1(i)=0;
for j=1:length(X1)
RecX1(i)=RecX1(i)+X1(j)*sinc((1/AddnumX1)*(i-AddnumX1*(j-1)));
denom1_1 = (i-AddnumX1*(j-1));
denom1_2 = ((pi/AddnumX1)*(i-AddnumX1*(j-1))^2);
if denom1_1 ~= 0 && denom1_2 ~= 0
RateX1(i) = RateX1(i) + X1(j)*(cos((pi/AddnumX1)*(i-AddnumX1*(j-1)))/denom1_1-sin((pi/AddnumX1)*(i-AddnumX1*(j-1)))/denom1_2);
end
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
mean_X1=mean(X1);
X1=X1-mean_X1;
mean_RecX1=mean(RecX1);
RecX1=RecX1-mean_RecX1;
0 个评论
采纳的回答
the cyclist
2023-3-18
编辑:the cyclist
2023-3-18
Your code is looking for a variable named X1. The file X1.mat that you load does not contain a variable named X1, it is just named X1. The file just has one variable named roi_signal_all.
Two possible solutions are
2 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!