Tag Archives: matlab
MATLAB Function to .NET Application Using MATLAB Data API for .NET with complex data structures (OrderedDictionary timetables)
How would the below example:
https://uk.mathworks.com/help/compiler_sdk/dotnet/deploy-mlcode-in-dotnetapp-using-ml-data-api-for-dotnet.html
such as:
A) pass a c# OrderedDictionary<date, double[]> to a matlab function (among other parameters, such as doubles & strings) and
B) Convert/Get that dictionary as a timetable in Matlab, on which operations to be made in the matlab function,
C) While returning a double[] array back into the .NET application?
The above usecase would be more useful as a started into a more complex environment involving timetables and c# dictionaries.How would the below example:
https://uk.mathworks.com/help/compiler_sdk/dotnet/deploy-mlcode-in-dotnetapp-using-ml-data-api-for-dotnet.html
such as:
A) pass a c# OrderedDictionary<date, double[]> to a matlab function (among other parameters, such as doubles & strings) and
B) Convert/Get that dictionary as a timetable in Matlab, on which operations to be made in the matlab function,
C) While returning a double[] array back into the .NET application?
The above usecase would be more useful as a started into a more complex environment involving timetables and c# dictionaries. How would the below example:
https://uk.mathworks.com/help/compiler_sdk/dotnet/deploy-mlcode-in-dotnetapp-using-ml-data-api-for-dotnet.html
such as:
A) pass a c# OrderedDictionary<date, double[]> to a matlab function (among other parameters, such as doubles & strings) and
B) Convert/Get that dictionary as a timetable in Matlab, on which operations to be made in the matlab function,
C) While returning a double[] array back into the .NET application?
The above usecase would be more useful as a started into a more complex environment involving timetables and c# dictionaries. matlab function, finance, .net, c# MATLAB Answers — New Questions
Datetime/Duration Error: Input data must be one numeric matrix when converting from a different date/time representation.
Since a previous post’s solution with the same datetime error didn’t work on my end, I made this post.
I am trying to combine Date and Time variables by datetime and duration them respectively from a 1454×7 table labelled "buoyF".
buoyF = renamevars(buoyF, {‘Var1’, ‘Var2’, ‘Var3’, ‘Var4’, ‘Var5’, ‘Var6’, ‘Var7’}, …
{‘Date’, ‘Time’, ‘East’, ‘North’, ‘Speed’, ‘Water Direction’, ‘Temp’});
buoyF.Date = datetime(buoyF.Date, ‘ConvertFrom’, text, ‘Format’, ‘dd/MM/yyyy’);
buoyF.Time = duration(buoyF.Time,’ConvertFrom’, text, ‘Format’, ‘hh:mm:ss’);
buoyF.datetime = buoyF.Date+buoyF.TimeSince a previous post’s solution with the same datetime error didn’t work on my end, I made this post.
I am trying to combine Date and Time variables by datetime and duration them respectively from a 1454×7 table labelled "buoyF".
buoyF = renamevars(buoyF, {‘Var1’, ‘Var2’, ‘Var3’, ‘Var4’, ‘Var5’, ‘Var6’, ‘Var7’}, …
{‘Date’, ‘Time’, ‘East’, ‘North’, ‘Speed’, ‘Water Direction’, ‘Temp’});
buoyF.Date = datetime(buoyF.Date, ‘ConvertFrom’, text, ‘Format’, ‘dd/MM/yyyy’);
buoyF.Time = duration(buoyF.Time,’ConvertFrom’, text, ‘Format’, ‘hh:mm:ss’);
buoyF.datetime = buoyF.Date+buoyF.Time Since a previous post’s solution with the same datetime error didn’t work on my end, I made this post.
I am trying to combine Date and Time variables by datetime and duration them respectively from a 1454×7 table labelled "buoyF".
buoyF = renamevars(buoyF, {‘Var1’, ‘Var2’, ‘Var3’, ‘Var4’, ‘Var5’, ‘Var6’, ‘Var7’}, …
{‘Date’, ‘Time’, ‘East’, ‘North’, ‘Speed’, ‘Water Direction’, ‘Temp’});
buoyF.Date = datetime(buoyF.Date, ‘ConvertFrom’, text, ‘Format’, ‘dd/MM/yyyy’);
buoyF.Time = duration(buoyF.Time,’ConvertFrom’, text, ‘Format’, ‘hh:mm:ss’);
buoyF.datetime = buoyF.Date+buoyF.Time datetime, duration MATLAB Answers — New Questions
Why the height of the bar3 decreases from original value as the size of the plot is varied?
I am trying to get a 3D bar plot with some titled layout, however the height of the bars tend to decrease from its original values. I have attached the codes below. please suggest how to correct this.
data_K=[0.8741,0.7742,0.7410,0.7488];
data_S=[0.9438,0.8490,0.7821,0.7330];
data_G=[0.8992,0.8496,0.8082,0.7685];
data_TS_F1=[data_K;data_S;data_G]*100;
f=figure(‘visible’, ‘on’,’GraphicsSmoothing’,’on’,’WindowStyle’,’docked’);
grid on;
t1 = tiledlayout(1,1,’Padding’,’tight’);
t1.Units = ‘inches’;
t1.OuterPosition = [0.40 0.05 2 1.6];
nexttile;
hp=bar3(data_TS);
set(gca, ‘XTick’, 1:width(data_TS), ‘XTickLabels’, {‘KNN’,’SVM’,’GNB’}, …
‘YTick’, 1:4, ‘YTickLabels’, [1,3,6,12],’FontName’,"Times New Roman","FontSize",12, ‘ZTick’,0:10:100);
ax=gca;
ax.FontWeight = ‘bold’;
set(hp(:),’facecolor’,[0.745000000000000 0.745000000000000 1]);
xtickangle(0);
ytickangle(0);I am trying to get a 3D bar plot with some titled layout, however the height of the bars tend to decrease from its original values. I have attached the codes below. please suggest how to correct this.
data_K=[0.8741,0.7742,0.7410,0.7488];
data_S=[0.9438,0.8490,0.7821,0.7330];
data_G=[0.8992,0.8496,0.8082,0.7685];
data_TS_F1=[data_K;data_S;data_G]*100;
f=figure(‘visible’, ‘on’,’GraphicsSmoothing’,’on’,’WindowStyle’,’docked’);
grid on;
t1 = tiledlayout(1,1,’Padding’,’tight’);
t1.Units = ‘inches’;
t1.OuterPosition = [0.40 0.05 2 1.6];
nexttile;
hp=bar3(data_TS);
set(gca, ‘XTick’, 1:width(data_TS), ‘XTickLabels’, {‘KNN’,’SVM’,’GNB’}, …
‘YTick’, 1:4, ‘YTickLabels’, [1,3,6,12],’FontName’,"Times New Roman","FontSize",12, ‘ZTick’,0:10:100);
ax=gca;
ax.FontWeight = ‘bold’;
set(hp(:),’facecolor’,[0.745000000000000 0.745000000000000 1]);
xtickangle(0);
ytickangle(0); I am trying to get a 3D bar plot with some titled layout, however the height of the bars tend to decrease from its original values. I have attached the codes below. please suggest how to correct this.
data_K=[0.8741,0.7742,0.7410,0.7488];
data_S=[0.9438,0.8490,0.7821,0.7330];
data_G=[0.8992,0.8496,0.8082,0.7685];
data_TS_F1=[data_K;data_S;data_G]*100;
f=figure(‘visible’, ‘on’,’GraphicsSmoothing’,’on’,’WindowStyle’,’docked’);
grid on;
t1 = tiledlayout(1,1,’Padding’,’tight’);
t1.Units = ‘inches’;
t1.OuterPosition = [0.40 0.05 2 1.6];
nexttile;
hp=bar3(data_TS);
set(gca, ‘XTick’, 1:width(data_TS), ‘XTickLabels’, {‘KNN’,’SVM’,’GNB’}, …
‘YTick’, 1:4, ‘YTickLabels’, [1,3,6,12],’FontName’,"Times New Roman","FontSize",12, ‘ZTick’,0:10:100);
ax=gca;
ax.FontWeight = ‘bold’;
set(hp(:),’facecolor’,[0.745000000000000 0.745000000000000 1]);
xtickangle(0);
ytickangle(0); 3d plots, bar3 MATLAB Answers — New Questions
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B), Source=MathWorks.MATLAB.Types
Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Engine.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Runtime.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Types.dll
within your static void Main(string[] args) function, add:
MATLABEngine engine = MATLABEngine.StartMATLAB();
This will produce:
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=MathWorks.MATLAB.Types
StackTrace:
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.array_factory_create_v2(ArrayFactoryHandle& factory)
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.ArrayFactoryCreate()
at MathWorks.MATLAB.Types.Impl.MATLABArrayFactoryImpl..ctor()
at MathWorks.MATLAB.Types.MATLABArrayFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngineFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngine.StartMATLAB()
Any ideas what’s the problem?Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Engine.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Runtime.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Types.dll
within your static void Main(string[] args) function, add:
MATLABEngine engine = MATLABEngine.StartMATLAB();
This will produce:
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=MathWorks.MATLAB.Types
StackTrace:
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.array_factory_create_v2(ArrayFactoryHandle& factory)
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.ArrayFactoryCreate()
at MathWorks.MATLAB.Types.Impl.MATLABArrayFactoryImpl..ctor()
at MathWorks.MATLAB.Types.MATLABArrayFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngineFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngine.StartMATLAB()
Any ideas what’s the problem? Reproduce:
Within a Visual Studio Windows Console app, add references to:
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Engine.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Runtime.dll
C:Program FilesMATLABR2024bexterndotnetnetstandard2.0MathWorks.MATLAB.Types.dll
within your static void Main(string[] args) function, add:
MATLABEngine engine = MATLABEngine.StartMATLAB();
This will produce:
System.BadImageFormatException
HResult=0x8007000B
Message=An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
Source=MathWorks.MATLAB.Types
StackTrace:
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.array_factory_create_v2(ArrayFactoryHandle& factory)
at MathWorks.MATLAB.Types.SafeHandles.ArrayFactoryHandle.ArrayFactoryCreate()
at MathWorks.MATLAB.Types.Impl.MATLABArrayFactoryImpl..ctor()
at MathWorks.MATLAB.Types.MATLABArrayFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngineFactory.get_Default()
at MathWorks.MATLAB.Engine.MATLABEngine.StartMATLAB()
Any ideas what’s the problem? matlab, matlab engine api for .net, .net MATLAB Answers — New Questions
how assign array in structure
[Sis.Slippage]
K>> [Sis.Slippage]
ans =
Columns 1 through 12
3 3 3 3 3 3 3 3 3 3 4 4
i want to moltiply x 0.5 and reassign it to the struct
l=[Sis.Slippage]*0.5;
[Sis.Slippage]=deal(l);
it’s not correct…
I was already given the solution but I can’t find it :([Sis.Slippage]
K>> [Sis.Slippage]
ans =
Columns 1 through 12
3 3 3 3 3 3 3 3 3 3 4 4
i want to moltiply x 0.5 and reassign it to the struct
l=[Sis.Slippage]*0.5;
[Sis.Slippage]=deal(l);
it’s not correct…
I was already given the solution but I can’t find it 🙁 [Sis.Slippage]
K>> [Sis.Slippage]
ans =
Columns 1 through 12
3 3 3 3 3 3 3 3 3 3 4 4
i want to moltiply x 0.5 and reassign it to the struct
l=[Sis.Slippage]*0.5;
[Sis.Slippage]=deal(l);
it’s not correct…
I was already given the solution but I can’t find it 🙁 how assign array in structure MATLAB Answers — New Questions
Why am I getting the same R-squared values?
Hello, I have a littel problem, when i use fitlm() i keep on getting the same same values for different models. I thought my original models were the wrong ones but I tried with known models as shown in the code attached. I keep on getting the same R-squared values for all the models of which am sure that should not be the case, is there a problem with my code? Please check and assist. Beacsue I suspect maybe there is something wrong with my code. I have attached a sample data which can easily be found in google doc with link provided here "https://docs.google.com/spreadsheets/d/10rK3bswrKyG_BiLRNHtIDBF6vEKo-zdzDTtdPu7KRd8/edit?usp=sharing"
%Wind_data =25*rand(100000,1);
A=input(‘enter wind speed matrixn’)
%second phase of filtration
nrows= numel(A);
ncols=1;
for i=1:nrows
for j=1:ncols
if A(i,j)<0
A(i,j)=0.1;
elseif A(i,j)>25
A(i,j)=25;
elseif A(i,j)==0
A(i,j)=0.5;
else
end
end
end
Wind_data=A;
Param_rayl=raylfit(sort(Wind_data),0.05);
Ray_pdf = raylpdf(sort(Wind_data),Param_rayl);
Ray_cdf = raylcdf(sort(Wind_data),Param_rayl);
figure
%plot(sort(Wind_data),Ray_pdf)
%figure
%plot(sort(Wind_data),Ray_cdf)
%Inverse Weibull
[Params_weibull]=wblfit(Wind_data);
Weibull_inv=wblinv(sort(Wind_data),Params_weibull(1),Params_weibull(2));%cdf of inverse weibull
figure
%plot(sort(Wind_data),Weibull_inv);
%gamma probability density distribution
[Param_gamma]=gamfit(sort(Wind_data))%prarameters determination
Gamma_pdf=gampdf(sort(Wind_data),Param_gamma(1),Param_gamma(2));%gama pdf
Gamma_cdf=gamcdf(sort(Wind_data),Param_gamma(1),Param_gamma(2));%gamma cdf
%figure
%plot(sort(Wind_data),Gamma_pdf);
%figure
%plot(sort(Wind_data),Gamma_cdf);
%extreme value distribution
[Params_evpdf]=evfit(sort(Wind_data));
Gumbel_evpdf=evpdf(sort(Wind_data),Params_evpdf(1),Params_evpdf(2));
Gumbel_evcdf=evcdf(sort(Wind_data),Params_evpdf(1),Params_evpdf(2));
%figure
%plot(sort(Wind_data),Gumbel_evpdf);
%figure
%plot(sort(Wind_data),Gumbel_evcdf);
Combined_cdfs=[Ray_cdf Gamma_cdf Gumbel_evcdf];
Empc=ecdf(Wind_data);
%weibull cumulative
%group the Estc1
figure
Hs_ray=histogram(Ray_cdf,numel(Empc));
binEdges_ray = Hs_ray.BinEdges;
x1 = binEdges_ray(1:end-1) + Hs_ray.BinWidth/2;
R1=fitlm(Empc,x1′)
%group the Estc_gamma
figure
Hs_gamma=histogram(Gamma_cdf,numel(Empc));
binEdges_gamma = Hs_gamma.BinEdges;
x2 = binEdges_gamma(1:end-1) + Hs_gamma.BinWidth/2;
R2=fitlm(Empc,x2′)
%group the Estc_gamma
figure
Hs_gumbell=histogram(Gumbel_evcdf,numel(Empc));
binEdges_gumbell = Hs_gumbell.BinEdges;
x3 = binEdges_gumbell(1:end-1) + Hs_gumbell.BinWidth/2;
R3=fitlm(Empc,x3′)
%trial-visualizaion
figure
cdfplot(Wind_data)
hold on
plot(sort(Wind_data),Ray_cdf)
plot(sort(Wind_data),Gamma_cdf)
plot(sort(Wind_data),Gumbel_evcdf);
hold off
legend(‘real’,’Ray’,’Gama’,’Gumbel’)Hello, I have a littel problem, when i use fitlm() i keep on getting the same same values for different models. I thought my original models were the wrong ones but I tried with known models as shown in the code attached. I keep on getting the same R-squared values for all the models of which am sure that should not be the case, is there a problem with my code? Please check and assist. Beacsue I suspect maybe there is something wrong with my code. I have attached a sample data which can easily be found in google doc with link provided here "https://docs.google.com/spreadsheets/d/10rK3bswrKyG_BiLRNHtIDBF6vEKo-zdzDTtdPu7KRd8/edit?usp=sharing"
%Wind_data =25*rand(100000,1);
A=input(‘enter wind speed matrixn’)
%second phase of filtration
nrows= numel(A);
ncols=1;
for i=1:nrows
for j=1:ncols
if A(i,j)<0
A(i,j)=0.1;
elseif A(i,j)>25
A(i,j)=25;
elseif A(i,j)==0
A(i,j)=0.5;
else
end
end
end
Wind_data=A;
Param_rayl=raylfit(sort(Wind_data),0.05);
Ray_pdf = raylpdf(sort(Wind_data),Param_rayl);
Ray_cdf = raylcdf(sort(Wind_data),Param_rayl);
figure
%plot(sort(Wind_data),Ray_pdf)
%figure
%plot(sort(Wind_data),Ray_cdf)
%Inverse Weibull
[Params_weibull]=wblfit(Wind_data);
Weibull_inv=wblinv(sort(Wind_data),Params_weibull(1),Params_weibull(2));%cdf of inverse weibull
figure
%plot(sort(Wind_data),Weibull_inv);
%gamma probability density distribution
[Param_gamma]=gamfit(sort(Wind_data))%prarameters determination
Gamma_pdf=gampdf(sort(Wind_data),Param_gamma(1),Param_gamma(2));%gama pdf
Gamma_cdf=gamcdf(sort(Wind_data),Param_gamma(1),Param_gamma(2));%gamma cdf
%figure
%plot(sort(Wind_data),Gamma_pdf);
%figure
%plot(sort(Wind_data),Gamma_cdf);
%extreme value distribution
[Params_evpdf]=evfit(sort(Wind_data));
Gumbel_evpdf=evpdf(sort(Wind_data),Params_evpdf(1),Params_evpdf(2));
Gumbel_evcdf=evcdf(sort(Wind_data),Params_evpdf(1),Params_evpdf(2));
%figure
%plot(sort(Wind_data),Gumbel_evpdf);
%figure
%plot(sort(Wind_data),Gumbel_evcdf);
Combined_cdfs=[Ray_cdf Gamma_cdf Gumbel_evcdf];
Empc=ecdf(Wind_data);
%weibull cumulative
%group the Estc1
figure
Hs_ray=histogram(Ray_cdf,numel(Empc));
binEdges_ray = Hs_ray.BinEdges;
x1 = binEdges_ray(1:end-1) + Hs_ray.BinWidth/2;
R1=fitlm(Empc,x1′)
%group the Estc_gamma
figure
Hs_gamma=histogram(Gamma_cdf,numel(Empc));
binEdges_gamma = Hs_gamma.BinEdges;
x2 = binEdges_gamma(1:end-1) + Hs_gamma.BinWidth/2;
R2=fitlm(Empc,x2′)
%group the Estc_gamma
figure
Hs_gumbell=histogram(Gumbel_evcdf,numel(Empc));
binEdges_gumbell = Hs_gumbell.BinEdges;
x3 = binEdges_gumbell(1:end-1) + Hs_gumbell.BinWidth/2;
R3=fitlm(Empc,x3′)
%trial-visualizaion
figure
cdfplot(Wind_data)
hold on
plot(sort(Wind_data),Ray_cdf)
plot(sort(Wind_data),Gamma_cdf)
plot(sort(Wind_data),Gumbel_evcdf);
hold off
legend(‘real’,’Ray’,’Gama’,’Gumbel’) Hello, I have a littel problem, when i use fitlm() i keep on getting the same same values for different models. I thought my original models were the wrong ones but I tried with known models as shown in the code attached. I keep on getting the same R-squared values for all the models of which am sure that should not be the case, is there a problem with my code? Please check and assist. Beacsue I suspect maybe there is something wrong with my code. I have attached a sample data which can easily be found in google doc with link provided here "https://docs.google.com/spreadsheets/d/10rK3bswrKyG_BiLRNHtIDBF6vEKo-zdzDTtdPu7KRd8/edit?usp=sharing"
%Wind_data =25*rand(100000,1);
A=input(‘enter wind speed matrixn’)
%second phase of filtration
nrows= numel(A);
ncols=1;
for i=1:nrows
for j=1:ncols
if A(i,j)<0
A(i,j)=0.1;
elseif A(i,j)>25
A(i,j)=25;
elseif A(i,j)==0
A(i,j)=0.5;
else
end
end
end
Wind_data=A;
Param_rayl=raylfit(sort(Wind_data),0.05);
Ray_pdf = raylpdf(sort(Wind_data),Param_rayl);
Ray_cdf = raylcdf(sort(Wind_data),Param_rayl);
figure
%plot(sort(Wind_data),Ray_pdf)
%figure
%plot(sort(Wind_data),Ray_cdf)
%Inverse Weibull
[Params_weibull]=wblfit(Wind_data);
Weibull_inv=wblinv(sort(Wind_data),Params_weibull(1),Params_weibull(2));%cdf of inverse weibull
figure
%plot(sort(Wind_data),Weibull_inv);
%gamma probability density distribution
[Param_gamma]=gamfit(sort(Wind_data))%prarameters determination
Gamma_pdf=gampdf(sort(Wind_data),Param_gamma(1),Param_gamma(2));%gama pdf
Gamma_cdf=gamcdf(sort(Wind_data),Param_gamma(1),Param_gamma(2));%gamma cdf
%figure
%plot(sort(Wind_data),Gamma_pdf);
%figure
%plot(sort(Wind_data),Gamma_cdf);
%extreme value distribution
[Params_evpdf]=evfit(sort(Wind_data));
Gumbel_evpdf=evpdf(sort(Wind_data),Params_evpdf(1),Params_evpdf(2));
Gumbel_evcdf=evcdf(sort(Wind_data),Params_evpdf(1),Params_evpdf(2));
%figure
%plot(sort(Wind_data),Gumbel_evpdf);
%figure
%plot(sort(Wind_data),Gumbel_evcdf);
Combined_cdfs=[Ray_cdf Gamma_cdf Gumbel_evcdf];
Empc=ecdf(Wind_data);
%weibull cumulative
%group the Estc1
figure
Hs_ray=histogram(Ray_cdf,numel(Empc));
binEdges_ray = Hs_ray.BinEdges;
x1 = binEdges_ray(1:end-1) + Hs_ray.BinWidth/2;
R1=fitlm(Empc,x1′)
%group the Estc_gamma
figure
Hs_gamma=histogram(Gamma_cdf,numel(Empc));
binEdges_gamma = Hs_gamma.BinEdges;
x2 = binEdges_gamma(1:end-1) + Hs_gamma.BinWidth/2;
R2=fitlm(Empc,x2′)
%group the Estc_gamma
figure
Hs_gumbell=histogram(Gumbel_evcdf,numel(Empc));
binEdges_gumbell = Hs_gumbell.BinEdges;
x3 = binEdges_gumbell(1:end-1) + Hs_gumbell.BinWidth/2;
R3=fitlm(Empc,x3′)
%trial-visualizaion
figure
cdfplot(Wind_data)
hold on
plot(sort(Wind_data),Ray_cdf)
plot(sort(Wind_data),Gamma_cdf)
plot(sort(Wind_data),Gumbel_evcdf);
hold off
legend(‘real’,’Ray’,’Gama’,’Gumbel’) code debbuging MATLAB Answers — New Questions
how to change an Online MATLAB (basic) to Online MATLAB
basic has a time limit. My students will need the no time limit version.
Can we change the versions or delete accounts and start over?basic has a time limit. My students will need the no time limit version.
Can we change the versions or delete accounts and start over? basic has a time limit. My students will need the no time limit version.
Can we change the versions or delete accounts and start over? online MATLAB Answers — New Questions
Exporting eeg data from eeg lab to use it in spm12
Does somebody know in which file format I have to export eeg data from eeglab when I want to further analyse it with spm12?Does somebody know in which file format I have to export eeg data from eeglab when I want to further analyse it with spm12? Does somebody know in which file format I have to export eeg data from eeglab when I want to further analyse it with spm12? eeglab, spm12, analysis, eeg, export, file MATLAB Answers — New Questions
How to change justification of text in live script?
From the aestetic point of view I’d like to know how to change justification of text in live script. Avaliable options are left, right or center but the one I need is not among them. I learned about changing live script appearance by commands settings.matlab…. etc, but can not find if it is possible to change justification this way. Thanks in advance.From the aestetic point of view I’d like to know how to change justification of text in live script. Avaliable options are left, right or center but the one I need is not among them. I learned about changing live script appearance by commands settings.matlab…. etc, but can not find if it is possible to change justification this way. Thanks in advance. From the aestetic point of view I’d like to know how to change justification of text in live script. Avaliable options are left, right or center but the one I need is not among them. I learned about changing live script appearance by commands settings.matlab…. etc, but can not find if it is possible to change justification this way. Thanks in advance. live script, appearance, matlab MATLAB Answers — New Questions
Viewing .slx model figue without Simulink
I have Matlab R2020a and R2022a, but no Simulink. I downloaded a free Intro SDR book from MathWorks. But the labs have .slx files. I would like to be able to view the model. I searched online and found this product:
DiffPlug unleashes Simulink’s potential
https://www.diffplug.com/features/simulink#trial
It looks like it will draw the figure given a .slx file. Do you know if this is true, and whether it is safe to use?
I hope to convert the blocks to Matlab so that I can follow the training material. I could not find any lab training material from MathWorks that just uses Matlab. (I know that there are examples, but I wanted to follow a lab setup.)
Thanks,
PaulI have Matlab R2020a and R2022a, but no Simulink. I downloaded a free Intro SDR book from MathWorks. But the labs have .slx files. I would like to be able to view the model. I searched online and found this product:
DiffPlug unleashes Simulink’s potential
https://www.diffplug.com/features/simulink#trial
It looks like it will draw the figure given a .slx file. Do you know if this is true, and whether it is safe to use?
I hope to convert the blocks to Matlab so that I can follow the training material. I could not find any lab training material from MathWorks that just uses Matlab. (I know that there are examples, but I wanted to follow a lab setup.)
Thanks,
Paul I have Matlab R2020a and R2022a, but no Simulink. I downloaded a free Intro SDR book from MathWorks. But the labs have .slx files. I would like to be able to view the model. I searched online and found this product:
DiffPlug unleashes Simulink’s potential
https://www.diffplug.com/features/simulink#trial
It looks like it will draw the figure given a .slx file. Do you know if this is true, and whether it is safe to use?
I hope to convert the blocks to Matlab so that I can follow the training material. I could not find any lab training material from MathWorks that just uses Matlab. (I know that there are examples, but I wanted to follow a lab setup.)
Thanks,
Paul matlab, .slx files, view .slx MATLAB Answers — New Questions
Characterisation error in HDL code generation?
When generating RTL code for VHDL for an Artix-7 using FPGA-In-The-Loop, I’m met with these error messages and only the first section of the design is characterised. The critical path is given as 0ns.
‘Error using hdlcoder.pirctx/buildCharacterizationData
Unexpected error during HDL Code Generation.
Contact support@mathworks.com with reproduction steps.
Assertion failed with debug message:
B:matlabsrccgir_hdltarget_analysisParameterizedDatabaseReader.cpp:101:paramChar
Error in characterization.readCharacterizationData
Error in slhdlcoder.HDLCoder/runPIRTransformAndCodegen
Error in slhdlcoder.HDLCoder/makehdl
Error in downstream.DownstreamIntegrationDriver/runGenerateRTLCodeAndTestbench
Error in runGenerateRTLCodeAndTestbench
Error in Simulink.ModelAdvisor/executeCheckCallbackFct
Error in Simulink.ModelAdvisor/run
Error in Simulink.ModelAdvisor/runCheck
Error in ModelAdvisor.Node/runTaskAdvisor’When generating RTL code for VHDL for an Artix-7 using FPGA-In-The-Loop, I’m met with these error messages and only the first section of the design is characterised. The critical path is given as 0ns.
‘Error using hdlcoder.pirctx/buildCharacterizationData
Unexpected error during HDL Code Generation.
Contact support@mathworks.com with reproduction steps.
Assertion failed with debug message:
B:matlabsrccgir_hdltarget_analysisParameterizedDatabaseReader.cpp:101:paramChar
Error in characterization.readCharacterizationData
Error in slhdlcoder.HDLCoder/runPIRTransformAndCodegen
Error in slhdlcoder.HDLCoder/makehdl
Error in downstream.DownstreamIntegrationDriver/runGenerateRTLCodeAndTestbench
Error in runGenerateRTLCodeAndTestbench
Error in Simulink.ModelAdvisor/executeCheckCallbackFct
Error in Simulink.ModelAdvisor/run
Error in Simulink.ModelAdvisor/runCheck
Error in ModelAdvisor.Node/runTaskAdvisor’ When generating RTL code for VHDL for an Artix-7 using FPGA-In-The-Loop, I’m met with these error messages and only the first section of the design is characterised. The critical path is given as 0ns.
‘Error using hdlcoder.pirctx/buildCharacterizationData
Unexpected error during HDL Code Generation.
Contact support@mathworks.com with reproduction steps.
Assertion failed with debug message:
B:matlabsrccgir_hdltarget_analysisParameterizedDatabaseReader.cpp:101:paramChar
Error in characterization.readCharacterizationData
Error in slhdlcoder.HDLCoder/runPIRTransformAndCodegen
Error in slhdlcoder.HDLCoder/makehdl
Error in downstream.DownstreamIntegrationDriver/runGenerateRTLCodeAndTestbench
Error in runGenerateRTLCodeAndTestbench
Error in Simulink.ModelAdvisor/executeCheckCallbackFct
Error in Simulink.ModelAdvisor/run
Error in Simulink.ModelAdvisor/runCheck
Error in ModelAdvisor.Node/runTaskAdvisor’ code generation, error, hdl coder MATLAB Answers — New Questions
I have shifted from lsqnoneg to lsqlin because lsqnonneg does not support additional constraint is it right or wrong choice?
Hi , i am working on laser absorption spectroscopy tomography and i am trying to find my X for AX = b form as b is my data and A is my coefficent matrix and i am using lsqnoeng as my solver , some how when i have to appy the constraint during the reconstruction of X ,then lsqnonneg does not support it, because of it i have shift to lsqlin and setting its lower bound zero or non zero , i am considering it will work like lsqnonneg solver , now i can easily apply constraint into it, but the problem is i am confused whether i did it rigth or wrong as for the better result in lsqlin i have to scale my data b with it maximum value other wise it give very bad results , or i should implement the lsqnoeng and then apply constraint into it , please guide meHi , i am working on laser absorption spectroscopy tomography and i am trying to find my X for AX = b form as b is my data and A is my coefficent matrix and i am using lsqnoeng as my solver , some how when i have to appy the constraint during the reconstruction of X ,then lsqnonneg does not support it, because of it i have shift to lsqlin and setting its lower bound zero or non zero , i am considering it will work like lsqnonneg solver , now i can easily apply constraint into it, but the problem is i am confused whether i did it rigth or wrong as for the better result in lsqlin i have to scale my data b with it maximum value other wise it give very bad results , or i should implement the lsqnoeng and then apply constraint into it , please guide me Hi , i am working on laser absorption spectroscopy tomography and i am trying to find my X for AX = b form as b is my data and A is my coefficent matrix and i am using lsqnoeng as my solver , some how when i have to appy the constraint during the reconstruction of X ,then lsqnonneg does not support it, because of it i have shift to lsqlin and setting its lower bound zero or non zero , i am considering it will work like lsqnonneg solver , now i can easily apply constraint into it, but the problem is i am confused whether i did it rigth or wrong as for the better result in lsqlin i have to scale my data b with it maximum value other wise it give very bad results , or i should implement the lsqnoeng and then apply constraint into it , please guide me lsqnoneg, lsqlin MATLAB Answers — New Questions
Exporting a code from Maple to Matlab
I use Matlab for numerical calculations.
But I use Maple for symbolic calculations and after the calculations I usually get piecewise functions in my maple codes.
I think the 3d plots in Matlab is very attractive more than Maple plots. So, I want to export piecewise functions in maple to a Matlab code in order to utilize advantages of plots of Matlab.
MAPLE CODE
restart:
u:=1/(1. + exp(x))^2 + 1/(1. + exp(-5.*t))^2 – 0.2500000000 + x*(1/(1. + exp(1 – 5*t))^2 – 1./((1. + exp(-5*t))^2) + 0.1776705118 + 0.0415431679756514*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + 0.00922094377856479*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t – 7.745966692, 0.) + 0.0603742508215732*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) – 0.00399645630498528*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t – 23.23790008, 0.)) + (-0.00243051684581302*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000809061198761621*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.0152377552205917*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.00195593427342862*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + (-0.000433590063316381*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000146112803263678*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.00319022339097685*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.000477063086307787*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t – 7.745966692, 0.) + (-0.00276114805649180*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000933166016624500*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.0207984584912892*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.00314360556336114*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) + (0.000172746997599710*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) + 0.0000586775450031145*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) + 0.00136190009033518*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) + 0.000211410172315387*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t – 23.23790008, 0.):
>
plot3d( u,
x=0..1,
t=0..1,
style=surface,
axes=boxed,
colorscheme=[yellow, red]
);
We can transform a maple code to Matlab code by using
with(CodeGeneration):
Matlab(u,resultname="w");
. But The code can’ t properly transform to Matlab code.
Could you help me plsI use Matlab for numerical calculations.
But I use Maple for symbolic calculations and after the calculations I usually get piecewise functions in my maple codes.
I think the 3d plots in Matlab is very attractive more than Maple plots. So, I want to export piecewise functions in maple to a Matlab code in order to utilize advantages of plots of Matlab.
MAPLE CODE
restart:
u:=1/(1. + exp(x))^2 + 1/(1. + exp(-5.*t))^2 – 0.2500000000 + x*(1/(1. + exp(1 – 5*t))^2 – 1./((1. + exp(-5*t))^2) + 0.1776705118 + 0.0415431679756514*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + 0.00922094377856479*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t – 7.745966692, 0.) + 0.0603742508215732*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) – 0.00399645630498528*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t – 23.23790008, 0.)) + (-0.00243051684581302*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000809061198761621*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.0152377552205917*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.00195593427342862*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + (-0.000433590063316381*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000146112803263678*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.00319022339097685*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.000477063086307787*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t – 7.745966692, 0.) + (-0.00276114805649180*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000933166016624500*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.0207984584912892*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.00314360556336114*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) + (0.000172746997599710*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) + 0.0000586775450031145*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) + 0.00136190009033518*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) + 0.000211410172315387*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t – 23.23790008, 0.):
>
plot3d( u,
x=0..1,
t=0..1,
style=surface,
axes=boxed,
colorscheme=[yellow, red]
);
We can transform a maple code to Matlab code by using
with(CodeGeneration):
Matlab(u,resultname="w");
. But The code can’ t properly transform to Matlab code.
Could you help me pls I use Matlab for numerical calculations.
But I use Maple for symbolic calculations and after the calculations I usually get piecewise functions in my maple codes.
I think the 3d plots in Matlab is very attractive more than Maple plots. So, I want to export piecewise functions in maple to a Matlab code in order to utilize advantages of plots of Matlab.
MAPLE CODE
restart:
u:=1/(1. + exp(x))^2 + 1/(1. + exp(-5.*t))^2 – 0.2500000000 + x*(1/(1. + exp(1 – 5*t))^2 – 1./((1. + exp(-5*t))^2) + 0.1776705118 + 0.0415431679756514*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + 0.00922094377856479*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t – 7.745966692, 0.) + 0.0603742508215732*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) – 0.00399645630498528*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t – 23.23790008, 0.)) + (-0.00243051684581302*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000809061198761621*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.0152377552205917*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.00195593427342862*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 1.732050808, 0.) + (-0.000433590063316381*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000146112803263678*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.00319022339097685*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.000477063086307787*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0. <= t and t <= 0.5000000000, 30.98386677*t – 7.745966692, 0.) + (-0.00276114805649180*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) – 0.000933166016624500*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) – 0.0207984584912892*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) – 0.00314360556336114*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 1.732050808, 0.) + (0.000172746997599710*piecewise(0. <= x and x <= 0.5000000000, 1.732050808, 0.) + 0.0000586775450031145*piecewise(0. <= x and x <= 0.5000000000, 30.98386677*x – 7.745966692, 0.) + 0.00136190009033518*piecewise(0.5000000000 <= x and x <= 1., 1.732050808, 0.) + 0.000211410172315387*piecewise(0.5000000000 <= x and x <= 1., 30.98386677*x – 23.23790008, 0.))*piecewise(0.5000000000 <= t and t <= 1., 30.98386677*t – 23.23790008, 0.):
>
plot3d( u,
x=0..1,
t=0..1,
style=surface,
axes=boxed,
colorscheme=[yellow, red]
);
We can transform a maple code to Matlab code by using
with(CodeGeneration):
Matlab(u,resultname="w");
. But The code can’ t properly transform to Matlab code.
Could you help me pls maple, matlab MATLAB Answers — New Questions
Shuffle method on custom datastore written for a single binary file
I am writing a custom datastore and am seeking some assistance. My datasets consist of stacks of 2D images (frames) stored sequentially in a single binary file. While it’s very straight forward to read in the binary stream using fread, each full dataset itself can easily be on the order of 50+ GB, making it infeasible to load everything at once on the hardware equipment I have available. This was my original motivation for exploring the use of a datastore.
In addition to the need for managing out-of-memory data, I also would like to partition the data into chunks where each chunk contains a random collection of frames from this binary file. If possible, I would like to use the shuffle method for the datastore superclass to accomplish this, as this seems to be the "proper" approach (although I’m very open to alternatives).
The problem I am currently having is that the default datastore shuffle method appears only to randomize the order of files in a datastore directory. However, since I only have one (very large) binary file, it doesn’t seem to "shuffle" anything at all – running readall on the shuffled datastore returns the exact same data as if I were to run it on the original datastore. I would rather need it to "shuffle" the frames within the binary file. Presumably, if I were to save each frame as an individual image file on disk, then I could get this to work using imageDatastore or fileDatastore. However, then I would have to go through all my files and save them to disk again as individual files, which seems rather silly.
I have written code to load a chunk of the data manually by jumping around the file using fseek. However, then I lose access to the datastore object as well as its built-in functionality. So I thought I would throw this question out there to see if anyone could offer some help.I am writing a custom datastore and am seeking some assistance. My datasets consist of stacks of 2D images (frames) stored sequentially in a single binary file. While it’s very straight forward to read in the binary stream using fread, each full dataset itself can easily be on the order of 50+ GB, making it infeasible to load everything at once on the hardware equipment I have available. This was my original motivation for exploring the use of a datastore.
In addition to the need for managing out-of-memory data, I also would like to partition the data into chunks where each chunk contains a random collection of frames from this binary file. If possible, I would like to use the shuffle method for the datastore superclass to accomplish this, as this seems to be the "proper" approach (although I’m very open to alternatives).
The problem I am currently having is that the default datastore shuffle method appears only to randomize the order of files in a datastore directory. However, since I only have one (very large) binary file, it doesn’t seem to "shuffle" anything at all – running readall on the shuffled datastore returns the exact same data as if I were to run it on the original datastore. I would rather need it to "shuffle" the frames within the binary file. Presumably, if I were to save each frame as an individual image file on disk, then I could get this to work using imageDatastore or fileDatastore. However, then I would have to go through all my files and save them to disk again as individual files, which seems rather silly.
I have written code to load a chunk of the data manually by jumping around the file using fseek. However, then I lose access to the datastore object as well as its built-in functionality. So I thought I would throw this question out there to see if anyone could offer some help. I am writing a custom datastore and am seeking some assistance. My datasets consist of stacks of 2D images (frames) stored sequentially in a single binary file. While it’s very straight forward to read in the binary stream using fread, each full dataset itself can easily be on the order of 50+ GB, making it infeasible to load everything at once on the hardware equipment I have available. This was my original motivation for exploring the use of a datastore.
In addition to the need for managing out-of-memory data, I also would like to partition the data into chunks where each chunk contains a random collection of frames from this binary file. If possible, I would like to use the shuffle method for the datastore superclass to accomplish this, as this seems to be the "proper" approach (although I’m very open to alternatives).
The problem I am currently having is that the default datastore shuffle method appears only to randomize the order of files in a datastore directory. However, since I only have one (very large) binary file, it doesn’t seem to "shuffle" anything at all – running readall on the shuffled datastore returns the exact same data as if I were to run it on the original datastore. I would rather need it to "shuffle" the frames within the binary file. Presumably, if I were to save each frame as an individual image file on disk, then I could get this to work using imageDatastore or fileDatastore. However, then I would have to go through all my files and save them to disk again as individual files, which seems rather silly.
I have written code to load a chunk of the data manually by jumping around the file using fseek. However, then I lose access to the datastore object as well as its built-in functionality. So I thought I would throw this question out there to see if anyone could offer some help. datastore, binary, shuffle, image stack, big data, large file, data import MATLAB Answers — New Questions
Hi, Why the error curve is not the subtraction of the Vin and Vout?
Post Content Post Content adc MATLAB Answers — New Questions
How to get the longest consecutive values in a column vector and the position at which it starts
Hello,
Suppose i have a single column vector A’=[0 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1]
I only want the longest consecutive values of 1’s and display only that.
I’d really appreciate any help!Hello,
Suppose i have a single column vector A’=[0 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1]
I only want the longest consecutive values of 1’s and display only that.
I’d really appreciate any help! Hello,
Suppose i have a single column vector A’=[0 0 0 1 0 1 1 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1]
I only want the longest consecutive values of 1’s and display only that.
I’d really appreciate any help! consecutive, longest, identical MATLAB Answers — New Questions
Why is my hamming window and rectangular window values the same for sigma_omega when I make L = 21?
I have this code that produces the same value for both the hamming window and the rectangular window when I try to solve for sigma_omega for given L (L = 21, 51, and 101). For the sake of the code I will only be testing for L = 21.
Here is the equation for sigma_omega:
Here is the code I have:
% Set window length L = 21
L = 21;
% Generate rectangular and Hamming windows
rect_window = window(@rectwin, L);
hamming_window = window(@hamming, L);
% Calculate the frequency spread for each window
sigma_omega_rect = calc_freq_spread(rect_window);
sigma_omega_hamming = calc_freq_spread(hamming_window);
% Display the frequency spread for rectangular and Hamming windows for L = 21
fprintf(‘L = 21: sigma_omega (Rectangular) = %.4fn’, sigma_omega_rect);
fprintf(‘L = 21: sigma_omega (Hamming) = %.4fnn’, sigma_omega_hamming);
% Function to calculate frequency spread
function sigma_omega = calc_freq_spread(w)
L = length(w);
% Calculate DTFT (using FFT as an approximation)
N = 1024; % Length of the FFT to improve frequency resolution
W = fft(w, N); % Compute the FFT of the window
% Frequency axis (normalized frequency ω from -π to π)
omega_hat = linspace(-pi, pi, N);
% Magnitude squared of DTFT
W_mag_sq = abs(W).^2;
% Numerator: Sum of ω^2 * |W(e^jω)|^2 (approximating the integral)
numerator = sum((omega_hat.^2) .* W_mag_sq);
% Denominator: Sum of |W(e^jω)|^2 (approximating the integral)
denominator = sum(W_mag_sq);
% Calculate the frequency spread (σ_ω)
sigma_omega = sqrt(sum(numerator) / sum(denominator)); % Summing the whole thing to a scalar
end
My question is what is wrong with my code for producing the same output? The same exact output for both rectangular and hamming window is also the same 58.0983 when I change L to either 51 or 101. Please advise.
Thank you.I have this code that produces the same value for both the hamming window and the rectangular window when I try to solve for sigma_omega for given L (L = 21, 51, and 101). For the sake of the code I will only be testing for L = 21.
Here is the equation for sigma_omega:
Here is the code I have:
% Set window length L = 21
L = 21;
% Generate rectangular and Hamming windows
rect_window = window(@rectwin, L);
hamming_window = window(@hamming, L);
% Calculate the frequency spread for each window
sigma_omega_rect = calc_freq_spread(rect_window);
sigma_omega_hamming = calc_freq_spread(hamming_window);
% Display the frequency spread for rectangular and Hamming windows for L = 21
fprintf(‘L = 21: sigma_omega (Rectangular) = %.4fn’, sigma_omega_rect);
fprintf(‘L = 21: sigma_omega (Hamming) = %.4fnn’, sigma_omega_hamming);
% Function to calculate frequency spread
function sigma_omega = calc_freq_spread(w)
L = length(w);
% Calculate DTFT (using FFT as an approximation)
N = 1024; % Length of the FFT to improve frequency resolution
W = fft(w, N); % Compute the FFT of the window
% Frequency axis (normalized frequency ω from -π to π)
omega_hat = linspace(-pi, pi, N);
% Magnitude squared of DTFT
W_mag_sq = abs(W).^2;
% Numerator: Sum of ω^2 * |W(e^jω)|^2 (approximating the integral)
numerator = sum((omega_hat.^2) .* W_mag_sq);
% Denominator: Sum of |W(e^jω)|^2 (approximating the integral)
denominator = sum(W_mag_sq);
% Calculate the frequency spread (σ_ω)
sigma_omega = sqrt(sum(numerator) / sum(denominator)); % Summing the whole thing to a scalar
end
My question is what is wrong with my code for producing the same output? The same exact output for both rectangular and hamming window is also the same 58.0983 when I change L to either 51 or 101. Please advise.
Thank you. I have this code that produces the same value for both the hamming window and the rectangular window when I try to solve for sigma_omega for given L (L = 21, 51, and 101). For the sake of the code I will only be testing for L = 21.
Here is the equation for sigma_omega:
Here is the code I have:
% Set window length L = 21
L = 21;
% Generate rectangular and Hamming windows
rect_window = window(@rectwin, L);
hamming_window = window(@hamming, L);
% Calculate the frequency spread for each window
sigma_omega_rect = calc_freq_spread(rect_window);
sigma_omega_hamming = calc_freq_spread(hamming_window);
% Display the frequency spread for rectangular and Hamming windows for L = 21
fprintf(‘L = 21: sigma_omega (Rectangular) = %.4fn’, sigma_omega_rect);
fprintf(‘L = 21: sigma_omega (Hamming) = %.4fnn’, sigma_omega_hamming);
% Function to calculate frequency spread
function sigma_omega = calc_freq_spread(w)
L = length(w);
% Calculate DTFT (using FFT as an approximation)
N = 1024; % Length of the FFT to improve frequency resolution
W = fft(w, N); % Compute the FFT of the window
% Frequency axis (normalized frequency ω from -π to π)
omega_hat = linspace(-pi, pi, N);
% Magnitude squared of DTFT
W_mag_sq = abs(W).^2;
% Numerator: Sum of ω^2 * |W(e^jω)|^2 (approximating the integral)
numerator = sum((omega_hat.^2) .* W_mag_sq);
% Denominator: Sum of |W(e^jω)|^2 (approximating the integral)
denominator = sum(W_mag_sq);
% Calculate the frequency spread (σ_ω)
sigma_omega = sqrt(sum(numerator) / sum(denominator)); % Summing the whole thing to a scalar
end
My question is what is wrong with my code for producing the same output? The same exact output for both rectangular and hamming window is also the same 58.0983 when I change L to either 51 or 101. Please advise.
Thank you. digital signal processing, frequency, mathematics MATLAB Answers — New Questions
Code generation information file does not exist
Hello everyone
After I made the configuration of the matlab and simulink packages for Arduino,and when I connected my arduino to my laptop I got this error when I clicked on run in the simulink program in the part of hardware :
Starting build procedure for: ControlMotor Página de códigos activa: 1252 gmake: wrapper.mk: No such file or directory gmake: *** No rule to make target `wrapper.mk’. Stop. The make command returned an error of 2 ### Build procedure for ControlMotor aborted due to an error.
And also I got this last one:
Top model targets built: Model Action Rebuild Reason ======================================================================== ControlMotor Failed Code generation information file does not exist. 0 of 1 models built (0 models alr
Honestly I don’t know how to fix those errors .
Best regardsHello everyone
After I made the configuration of the matlab and simulink packages for Arduino,and when I connected my arduino to my laptop I got this error when I clicked on run in the simulink program in the part of hardware :
Starting build procedure for: ControlMotor Página de códigos activa: 1252 gmake: wrapper.mk: No such file or directory gmake: *** No rule to make target `wrapper.mk’. Stop. The make command returned an error of 2 ### Build procedure for ControlMotor aborted due to an error.
And also I got this last one:
Top model targets built: Model Action Rebuild Reason ======================================================================== ControlMotor Failed Code generation information file does not exist. 0 of 1 models built (0 models alr
Honestly I don’t know how to fix those errors .
Best regards Hello everyone
After I made the configuration of the matlab and simulink packages for Arduino,and when I connected my arduino to my laptop I got this error when I clicked on run in the simulink program in the part of hardware :
Starting build procedure for: ControlMotor Página de códigos activa: 1252 gmake: wrapper.mk: No such file or directory gmake: *** No rule to make target `wrapper.mk’. Stop. The make command returned an error of 2 ### Build procedure for ControlMotor aborted due to an error.
And also I got this last one:
Top model targets built: Model Action Rebuild Reason ======================================================================== ControlMotor Failed Code generation information file does not exist. 0 of 1 models built (0 models alr
Honestly I don’t know how to fix those errors .
Best regards wrapper.mk MATLAB Answers — New Questions
Need help with waypoint navigation code
Hello,
I’m having issues getting a simple waypoint navigation code to work. I am simulating the movement of an RC boat that should navigate from its current location and move to waypoints. Current location and waypoints are inputs and the distance to the waypoint and bearing are outputs. Once the last waypoint is reached, I want the boat to circle back to the first waypoint and the loop continues. What I have is as follows:
function [s, bearing] = waypoint_navigation(lat1, lon1, waypoints)
s=zeros(1);
bearing=zeros(1);
R = 6371e3; % Earth’s radius in meters
lat1 = deg2rad(lat1);
lon1 = deg2rad(lon1);
for i=1:length(waypoints)
lat2 = deg2rad(waypoints(i, 1));
lon2 = deg2rad(waypoints(i, 2));
[s(i), bearing(i)] = haversine_distance_and_bearing(lat1, lon1, lat2(i,1), lon2(i,1)); % haversine_distance_and_bearing is a custom function I’ve created
if s < 5 % Distance threshold
% Increment the waypoint index to go to the next waypoint
i = i + 1;
end
% Loop back to the first waypoint if at the last waypoint
if i > length(waypoints)
i = 1;
end
end
end
Running this results in the error: Error:An error occurred during simulation and the simulation was terminated
Caused by:
Index exceeds array dimensions. Index value 2 exceeds valid range [1-1] for array ‘lat2’.
Error in ‘Test_PlantID/Waypoint Navigation’ (line 11)
[s(i), bearing(i)] = haversine_distance_and_bearing(lat1, lon1, lat2(i,1), lon2(i,1));
I’d appreciate some help on this, I feel like I’m missing something very basic here. Thanks in advance!Hello,
I’m having issues getting a simple waypoint navigation code to work. I am simulating the movement of an RC boat that should navigate from its current location and move to waypoints. Current location and waypoints are inputs and the distance to the waypoint and bearing are outputs. Once the last waypoint is reached, I want the boat to circle back to the first waypoint and the loop continues. What I have is as follows:
function [s, bearing] = waypoint_navigation(lat1, lon1, waypoints)
s=zeros(1);
bearing=zeros(1);
R = 6371e3; % Earth’s radius in meters
lat1 = deg2rad(lat1);
lon1 = deg2rad(lon1);
for i=1:length(waypoints)
lat2 = deg2rad(waypoints(i, 1));
lon2 = deg2rad(waypoints(i, 2));
[s(i), bearing(i)] = haversine_distance_and_bearing(lat1, lon1, lat2(i,1), lon2(i,1)); % haversine_distance_and_bearing is a custom function I’ve created
if s < 5 % Distance threshold
% Increment the waypoint index to go to the next waypoint
i = i + 1;
end
% Loop back to the first waypoint if at the last waypoint
if i > length(waypoints)
i = 1;
end
end
end
Running this results in the error: Error:An error occurred during simulation and the simulation was terminated
Caused by:
Index exceeds array dimensions. Index value 2 exceeds valid range [1-1] for array ‘lat2’.
Error in ‘Test_PlantID/Waypoint Navigation’ (line 11)
[s(i), bearing(i)] = haversine_distance_and_bearing(lat1, lon1, lat2(i,1), lon2(i,1));
I’d appreciate some help on this, I feel like I’m missing something very basic here. Thanks in advance! Hello,
I’m having issues getting a simple waypoint navigation code to work. I am simulating the movement of an RC boat that should navigate from its current location and move to waypoints. Current location and waypoints are inputs and the distance to the waypoint and bearing are outputs. Once the last waypoint is reached, I want the boat to circle back to the first waypoint and the loop continues. What I have is as follows:
function [s, bearing] = waypoint_navigation(lat1, lon1, waypoints)
s=zeros(1);
bearing=zeros(1);
R = 6371e3; % Earth’s radius in meters
lat1 = deg2rad(lat1);
lon1 = deg2rad(lon1);
for i=1:length(waypoints)
lat2 = deg2rad(waypoints(i, 1));
lon2 = deg2rad(waypoints(i, 2));
[s(i), bearing(i)] = haversine_distance_and_bearing(lat1, lon1, lat2(i,1), lon2(i,1)); % haversine_distance_and_bearing is a custom function I’ve created
if s < 5 % Distance threshold
% Increment the waypoint index to go to the next waypoint
i = i + 1;
end
% Loop back to the first waypoint if at the last waypoint
if i > length(waypoints)
i = 1;
end
end
end
Running this results in the error: Error:An error occurred during simulation and the simulation was terminated
Caused by:
Index exceeds array dimensions. Index value 2 exceeds valid range [1-1] for array ‘lat2’.
Error in ‘Test_PlantID/Waypoint Navigation’ (line 11)
[s(i), bearing(i)] = haversine_distance_and_bearing(lat1, lon1, lat2(i,1), lon2(i,1));
I’d appreciate some help on this, I feel like I’m missing something very basic here. Thanks in advance! matlab, simulink, waypoints MATLAB Answers — New Questions
How to extract specific information from a table, an output when fitlm() function in sued
Hello, am curretly trying to compare several models to determine which one best explains the physical phenomenon. To do this, am using regression analysis to compare each model against the actual experimental data. In each comparsison, I get a table similar to the one below. I would like to pick each R-squared value for each model and store it in a matrix to allow me perform further analaysis.How do I go about this?Hello, am curretly trying to compare several models to determine which one best explains the physical phenomenon. To do this, am using regression analysis to compare each model against the actual experimental data. In each comparsison, I get a table similar to the one below. I would like to pick each R-squared value for each model and store it in a matrix to allow me perform further analaysis.How do I go about this? Hello, am curretly trying to compare several models to determine which one best explains the physical phenomenon. To do this, am using regression analysis to compare each model against the actual experimental data. In each comparsison, I get a table similar to the one below. I would like to pick each R-squared value for each model and store it in a matrix to allow me perform further analaysis.How do I go about this? how to extract info from table MATLAB Answers — New Questions