Author: PuTI
Why does the “goertzel” function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Why does the "goertzel" function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Specifically, I get a "Maximum Index exceeds the dimensions of X." error when running the following code:
>> Fs = 8000;
>> N = 205;
>> lo = sin(2*pi*697*(0:N-1)/Fs);
>> hi = sin(2*pi*1209*(0:N-1)/Fs);
>> data = lo + hi;
>> goertzel(data,205.5)
Error using goertzel (line 143)
Maximum Index exceeds the dimensions of X.
Error in goertzel (line 100)
Y1 = goertzel(reshape(X,coder.internal.indexInt(size(X,2)),ONE),INDVEC,1);Why does the "goertzel" function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Specifically, I get a "Maximum Index exceeds the dimensions of X." error when running the following code:
>> Fs = 8000;
>> N = 205;
>> lo = sin(2*pi*697*(0:N-1)/Fs);
>> hi = sin(2*pi*1209*(0:N-1)/Fs);
>> data = lo + hi;
>> goertzel(data,205.5)
Error using goertzel (line 143)
Maximum Index exceeds the dimensions of X.
Error in goertzel (line 100)
Y1 = goertzel(reshape(X,coder.internal.indexInt(size(X,2)),ONE),INDVEC,1); Why does the "goertzel" function not accept arguments in [N, N + 1) as the FFT index for signal inputs of length N in MATLAB R2024a and earlier?
Specifically, I get a "Maximum Index exceeds the dimensions of X." error when running the following code:
>> Fs = 8000;
>> N = 205;
>> lo = sin(2*pi*697*(0:N-1)/Fs);
>> hi = sin(2*pi*1209*(0:N-1)/Fs);
>> data = lo + hi;
>> goertzel(data,205.5)
Error using goertzel (line 143)
Maximum Index exceeds the dimensions of X.
Error in goertzel (line 100)
Y1 = goertzel(reshape(X,coder.internal.indexInt(size(X,2)),ONE),INDVEC,1); goertzel, signalprocessing MATLAB Answers — New Questions
How do I make shaded error bar area instead of lines?
I have data as a neuronal response function listed as my first line of code which is the curve I get. I am trying to add shaded error bars that look similar to this:
My code is:
load(‘0_RF_PSD95-3_20111121-3.CNG.swc_Trials_120_length_2000_p_0.995_a_0.8_beta_0.6.mat’)
SDdiff = std(diff(sort(Fsoma)));
figure; errorbar(h(2:end), diff(mean(Fsoma/500)), …
SDdiff(2:end)/500);
set(gca, ‘XScale’, ‘log’)
and my current figure/output is:
Does anyone know how to help me achieve something similar to the first figure? Thank you in advance.I have data as a neuronal response function listed as my first line of code which is the curve I get. I am trying to add shaded error bars that look similar to this:
My code is:
load(‘0_RF_PSD95-3_20111121-3.CNG.swc_Trials_120_length_2000_p_0.995_a_0.8_beta_0.6.mat’)
SDdiff = std(diff(sort(Fsoma)));
figure; errorbar(h(2:end), diff(mean(Fsoma/500)), …
SDdiff(2:end)/500);
set(gca, ‘XScale’, ‘log’)
and my current figure/output is:
Does anyone know how to help me achieve something similar to the first figure? Thank you in advance. I have data as a neuronal response function listed as my first line of code which is the curve I get. I am trying to add shaded error bars that look similar to this:
My code is:
load(‘0_RF_PSD95-3_20111121-3.CNG.swc_Trials_120_length_2000_p_0.995_a_0.8_beta_0.6.mat’)
SDdiff = std(diff(sort(Fsoma)));
figure; errorbar(h(2:end), diff(mean(Fsoma/500)), …
SDdiff(2:end)/500);
set(gca, ‘XScale’, ‘log’)
and my current figure/output is:
Does anyone know how to help me achieve something similar to the first figure? Thank you in advance. shadederrorbar, errorbar MATLAB Answers — New Questions
How to sending data from matlab to arduino?
I tried to learned some basic a sending data from matlab to arduino with a LED. i tried to turn on and off the LED if i changed some value in matlab. but the result that the LED is gived was always same. please help me to correct. my MATLAB code is
arduino=serial(‘COM3′,’BaudRate’,9600); % create serial communication object on port COM3
fopen(arduino); % initiate arduino communication
answer = 0.2
fprintf(arduino,%f%,answer); % send answer to arduino
fclose(arduino); % end communication with arduino
and my arduino code is
int ledPin=13;
int matlabdata;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0) // if there is data to read
{
matlabdata=Serial.read(); // read data
if(matlabdata<0.2)
digitalWrite(ledPin,HIGH); // turn light on
else if(matlabdata>0.2)
digitalWrite(ledPin,LOW); // turn light off
}
}I tried to learned some basic a sending data from matlab to arduino with a LED. i tried to turn on and off the LED if i changed some value in matlab. but the result that the LED is gived was always same. please help me to correct. my MATLAB code is
arduino=serial(‘COM3′,’BaudRate’,9600); % create serial communication object on port COM3
fopen(arduino); % initiate arduino communication
answer = 0.2
fprintf(arduino,%f%,answer); % send answer to arduino
fclose(arduino); % end communication with arduino
and my arduino code is
int ledPin=13;
int matlabdata;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0) // if there is data to read
{
matlabdata=Serial.read(); // read data
if(matlabdata<0.2)
digitalWrite(ledPin,HIGH); // turn light on
else if(matlabdata>0.2)
digitalWrite(ledPin,LOW); // turn light off
}
} I tried to learned some basic a sending data from matlab to arduino with a LED. i tried to turn on and off the LED if i changed some value in matlab. but the result that the LED is gived was always same. please help me to correct. my MATLAB code is
arduino=serial(‘COM3′,’BaudRate’,9600); % create serial communication object on port COM3
fopen(arduino); % initiate arduino communication
answer = 0.2
fprintf(arduino,%f%,answer); % send answer to arduino
fclose(arduino); % end communication with arduino
and my arduino code is
int ledPin=13;
int matlabdata;
void setup()
{
pinMode(ledPin,OUTPUT);
Serial.begin(9600);
}
void loop()
{
if(Serial.available()>0) // if there is data to read
{
matlabdata=Serial.read(); // read data
if(matlabdata<0.2)
digitalWrite(ledPin,HIGH); // turn light on
else if(matlabdata>0.2)
digitalWrite(ledPin,LOW); // turn light off
}
} matlab to arduino, arduino MATLAB Answers — New Questions
PX4 Serial Receive Variable Data Length
Hello,
I am currently trying to receive serial data from a UART&I2C Port in my simulink model. The data stream I am receiving has 6 signals with one singal being an iteration counter that increases from 1 – 1000. This means that the total character length of the serial pack is increasing as time progresses. I have no current way to alter the length of the transmission. When accepting signals that are longer than the prescribed length, valuable data is cut off. When accepting data that is shorter than the prescribed length, erroenous zeros are thrown in to the data making my signals have very jumpy time histories. The only time this system works is when the data is corrent length as specified in the serial receive PX4 block.
Is there a way for the PX4 Serial Receive block to handle a signal with a variable data length?
Furthermore, are there any work arounds with different serial receive blocks that can connect to the relevant ports on a Pixhawk 6x(dev/ttyS4)?Hello,
I am currently trying to receive serial data from a UART&I2C Port in my simulink model. The data stream I am receiving has 6 signals with one singal being an iteration counter that increases from 1 – 1000. This means that the total character length of the serial pack is increasing as time progresses. I have no current way to alter the length of the transmission. When accepting signals that are longer than the prescribed length, valuable data is cut off. When accepting data that is shorter than the prescribed length, erroenous zeros are thrown in to the data making my signals have very jumpy time histories. The only time this system works is when the data is corrent length as specified in the serial receive PX4 block.
Is there a way for the PX4 Serial Receive block to handle a signal with a variable data length?
Furthermore, are there any work arounds with different serial receive blocks that can connect to the relevant ports on a Pixhawk 6x(dev/ttyS4)? Hello,
I am currently trying to receive serial data from a UART&I2C Port in my simulink model. The data stream I am receiving has 6 signals with one singal being an iteration counter that increases from 1 – 1000. This means that the total character length of the serial pack is increasing as time progresses. I have no current way to alter the length of the transmission. When accepting signals that are longer than the prescribed length, valuable data is cut off. When accepting data that is shorter than the prescribed length, erroenous zeros are thrown in to the data making my signals have very jumpy time histories. The only time this system works is when the data is corrent length as specified in the serial receive PX4 block.
Is there a way for the PX4 Serial Receive block to handle a signal with a variable data length?
Furthermore, are there any work arounds with different serial receive blocks that can connect to the relevant ports on a Pixhawk 6x(dev/ttyS4)? px4, uav toolbox, serial receive, uart, ascii, data length MATLAB Answers — New Questions
How to print multiple graphs/figures in a for loop
Using this code all the figures flash very fast and then result in the last figure staying. How do I run this code and get all the graphs to print seperately?Using this code all the figures flash very fast and then result in the last figure staying. How do I run this code and get all the graphs to print seperately? Using this code all the figures flash very fast and then result in the last figure staying. How do I run this code and get all the graphs to print seperately? for loop, figures, graphs, plot MATLAB Answers — New Questions
solving symbolic array to output a numerical solution
Hi there, I was wondering if I could get some feedback on a potential solution for this problem. I am trying to solve for ma3 and obtain a numerical value for each value used in the FLcD3 array. However, the output of Ma3 is a struct with fields. How do I get it so the solution is an array with the numerical values? I’m guessing I would need some form of a for loop but i’m not quite sure how to set it up.
PSW = 0.36:0.03:0.69;
L12 = PSW*TL;
D = 0.03;
Ma4 = 1;
P4 = 1.013;
Lc3 = TL-L12;
FLcD3 = 4*f*Lc3/D;
ma3 = sym(‘ma3’, [1 length(PSW)]) ;
eqn1 = (-1./G).*(1-ma3.^-2)+((G+1)./(2.*G)).*log((((G+1)./2).*ma3.^2)./(1+((G-1)./2).*ma3.^2)) == FLcD3;
Ma3 = vpasolve(eqn1,ma3)
%This is the output I get
Ma3 =
ma31: [1×1 sym]
ma32: [1×1 sym]
ma33: [1×1 sym]
ma34: [1×1 sym]
ma35: [1×1 sym]
ma36: [1×1 sym]
ma37: [1×1 sym]
ma38: [1×1 sym]
ma39: [1×1 sym]
ma310: [1×1 sym]
ma311: [1×1 sym]
ma312: [1×1 sym]Hi there, I was wondering if I could get some feedback on a potential solution for this problem. I am trying to solve for ma3 and obtain a numerical value for each value used in the FLcD3 array. However, the output of Ma3 is a struct with fields. How do I get it so the solution is an array with the numerical values? I’m guessing I would need some form of a for loop but i’m not quite sure how to set it up.
PSW = 0.36:0.03:0.69;
L12 = PSW*TL;
D = 0.03;
Ma4 = 1;
P4 = 1.013;
Lc3 = TL-L12;
FLcD3 = 4*f*Lc3/D;
ma3 = sym(‘ma3’, [1 length(PSW)]) ;
eqn1 = (-1./G).*(1-ma3.^-2)+((G+1)./(2.*G)).*log((((G+1)./2).*ma3.^2)./(1+((G-1)./2).*ma3.^2)) == FLcD3;
Ma3 = vpasolve(eqn1,ma3)
%This is the output I get
Ma3 =
ma31: [1×1 sym]
ma32: [1×1 sym]
ma33: [1×1 sym]
ma34: [1×1 sym]
ma35: [1×1 sym]
ma36: [1×1 sym]
ma37: [1×1 sym]
ma38: [1×1 sym]
ma39: [1×1 sym]
ma310: [1×1 sym]
ma311: [1×1 sym]
ma312: [1×1 sym] Hi there, I was wondering if I could get some feedback on a potential solution for this problem. I am trying to solve for ma3 and obtain a numerical value for each value used in the FLcD3 array. However, the output of Ma3 is a struct with fields. How do I get it so the solution is an array with the numerical values? I’m guessing I would need some form of a for loop but i’m not quite sure how to set it up.
PSW = 0.36:0.03:0.69;
L12 = PSW*TL;
D = 0.03;
Ma4 = 1;
P4 = 1.013;
Lc3 = TL-L12;
FLcD3 = 4*f*Lc3/D;
ma3 = sym(‘ma3’, [1 length(PSW)]) ;
eqn1 = (-1./G).*(1-ma3.^-2)+((G+1)./(2.*G)).*log((((G+1)./2).*ma3.^2)./(1+((G-1)./2).*ma3.^2)) == FLcD3;
Ma3 = vpasolve(eqn1,ma3)
%This is the output I get
Ma3 =
ma31: [1×1 sym]
ma32: [1×1 sym]
ma33: [1×1 sym]
ma34: [1×1 sym]
ma35: [1×1 sym]
ma36: [1×1 sym]
ma37: [1×1 sym]
ma38: [1×1 sym]
ma39: [1×1 sym]
ma310: [1×1 sym]
ma311: [1×1 sym]
ma312: [1×1 sym] struct, solve, symbolic MATLAB Answers — New Questions
Porting Autogenerated C code from Deep learning toolbox to embedded environment
In ANN Auto C code all matrices are appearing as Static const variables which means that they will be RAM. These variables need to be in FLASH and always read from FLASH due to limitations in RAM size. How is it possible to customise the autocode from Matlab scripts to achieve this ?
Are there are any code generation configuration which allows us to achieve this ?
Please note that I am using MATLAB coder and M-scripts (not SIMULINK)In ANN Auto C code all matrices are appearing as Static const variables which means that they will be RAM. These variables need to be in FLASH and always read from FLASH due to limitations in RAM size. How is it possible to customise the autocode from Matlab scripts to achieve this ?
Are there are any code generation configuration which allows us to achieve this ?
Please note that I am using MATLAB coder and M-scripts (not SIMULINK) In ANN Auto C code all matrices are appearing as Static const variables which means that they will be RAM. These variables need to be in FLASH and always read from FLASH due to limitations in RAM size. How is it possible to customise the autocode from Matlab scripts to achieve this ?
Are there are any code generation configuration which allows us to achieve this ?
Please note that I am using MATLAB coder and M-scripts (not SIMULINK) embedded coder, matlab, deep learning, matlab coder MATLAB Answers — New Questions
plotting few values continuously in real time
i have data coming from the gps and i want to plot it for every one second. like a ecg graph. the values are like 560,940,780. please helpi have data coming from the gps and i want to plot it for every one second. like a ecg graph. the values are like 560,940,780. please help i have data coming from the gps and i want to plot it for every one second. like a ecg graph. the values are like 560,940,780. please help graphs MATLAB Answers — New Questions
Matlab spdiags function not do what I expect
B=[1 2 3;4 5 6;7 8 9;10 11 12]
d=[-3 0 2];
A=spdiags(B,d,4,7); %主对角线之下的对角线溢出时候,取最后一个值
B=spdiags(B,d,7,4); %主对角线之上的对角线溢出时候,取最后一个值
C=spdiags(B,d,4,4);
full(A)
full(B)
full(C)
Why would I get
ans =
2 0 3 0 0 0 0
0 5 0 6 0 0 0
0 0 8 0 9 0 0
10 0 0 11 0 12 0
ans =
2 0 9 0
0 5 0 12
0 0 8 0
1 0 0 11
0 4 0 0
0 0 7 0
0 0 0 10
ans =
0 0 8 0
0 5 0 0
0 0 0 0
2 0 0 0
Why is C so different from the previous two? In terms of having the numbers not shown on main diagnol and also having the numbers arranged from bottom to top?B=[1 2 3;4 5 6;7 8 9;10 11 12]
d=[-3 0 2];
A=spdiags(B,d,4,7); %主对角线之下的对角线溢出时候,取最后一个值
B=spdiags(B,d,7,4); %主对角线之上的对角线溢出时候,取最后一个值
C=spdiags(B,d,4,4);
full(A)
full(B)
full(C)
Why would I get
ans =
2 0 3 0 0 0 0
0 5 0 6 0 0 0
0 0 8 0 9 0 0
10 0 0 11 0 12 0
ans =
2 0 9 0
0 5 0 12
0 0 8 0
1 0 0 11
0 4 0 0
0 0 7 0
0 0 0 10
ans =
0 0 8 0
0 5 0 0
0 0 0 0
2 0 0 0
Why is C so different from the previous two? In terms of having the numbers not shown on main diagnol and also having the numbers arranged from bottom to top? B=[1 2 3;4 5 6;7 8 9;10 11 12]
d=[-3 0 2];
A=spdiags(B,d,4,7); %主对角线之下的对角线溢出时候,取最后一个值
B=spdiags(B,d,7,4); %主对角线之上的对角线溢出时候,取最后一个值
C=spdiags(B,d,4,4);
full(A)
full(B)
full(C)
Why would I get
ans =
2 0 3 0 0 0 0
0 5 0 6 0 0 0
0 0 8 0 9 0 0
10 0 0 11 0 12 0
ans =
2 0 9 0
0 5 0 12
0 0 8 0
1 0 0 11
0 4 0 0
0 0 7 0
0 0 0 10
ans =
0 0 8 0
0 5 0 0
0 0 0 0
2 0 0 0
Why is C so different from the previous two? In terms of having the numbers not shown on main diagnol and also having the numbers arranged from bottom to top? matlab MATLAB Answers — New Questions
Why matlab is not as intelligent as python
I used python before and when I add
#titile
to the python and I press Alt+3 to uncomment, it will not uncomment this because it know it is a title.
However, when I use the same trick in matlab script,
I press
%titile
This time when I uncomment, it reduces the %.
My question is why can python distinguish between #titile and # title, while matlab can’t distinguish from %title and % title?(note there is a space between % and the word title.)I used python before and when I add
#titile
to the python and I press Alt+3 to uncomment, it will not uncomment this because it know it is a title.
However, when I use the same trick in matlab script,
I press
%titile
This time when I uncomment, it reduces the %.
My question is why can python distinguish between #titile and # title, while matlab can’t distinguish from %title and % title?(note there is a space between % and the word title.) I used python before and when I add
#titile
to the python and I press Alt+3 to uncomment, it will not uncomment this because it know it is a title.
However, when I use the same trick in matlab script,
I press
%titile
This time when I uncomment, it reduces the %.
My question is why can python distinguish between #titile and # title, while matlab can’t distinguish from %title and % title?(note there is a space between % and the word title.) matlab MATLAB Answers — New Questions
-logfile option changes output
I am working on an Azure Pipeline. I need to echo the script output to the pipeline, and check the output to see if the stage failed. My current PowerShell code looks like this.
$cur_dir = $Env:AGENT_BUILDDIRECTORY
$log_file = Join-Path $cur_dir ‘log_file.txt’
$cmd = Join-Path $cur_dir ‘basemodeling_toolsmatlabstupid_permissions_workaround.m’
Write-Host $cmd
$args = "-logfile $log_file -nodisplay -nosplash -r run(‘$cmd’); exit();"
Start-Process matlab -ArgumentList $args -Wait
Get-Content $log_file | Write-Host
if ($log_file -match ‘TOTAL NUMBER OF FAILED BLOCKS:: 0’){
$rv = 0
}
The output saved in log_file.txt does not match the output when I run the script in Matlab. The output captured in log_file.txt is getting truncated, and I have no idea why. Is there a better way to capture the output than using the -logfile option?
Output when run inside MATLAB Output in log_file.txt
‘TOTAL NUMBER OF FAILED BLOCKS:: 38’ ‘TOTAL NUMBER OF FAILED BLOCKS:: 38’
{‘Check Name’ } {‘Time’ } {‘Check Name’ } {‘Time’ }
{["STD-MBD-098 Top Level Model" ]} {[1.1502]} {["STD-MBD-098 Top Level Model" ]} {[2.1924]}
{‘STD-MBD-122 Sample Time’ } {[0.1825]} {‘STD-MBD-122 Sample Time’ } {[0.3057]}
{‘STD-MBD-065 Relational Blocks’ } {[2.0332]} {‘STD-MBD-065 Relational Blocks’ } {[3.6043]}
{‘STD-MBD-163 Nested States Standard’ } {[0.0032]} {‘STD-MBD-163 Nested States Stand…’} {[0.0089]}
{‘STD-MBD-108 States Entry: During: Exit:’ } {[0.0198]} {‘STD-MBD-108 States Entry: Durin…’} {[0.0413]}
{‘STD-MBD-097 Foreground color’ } {[0.1659]} {‘STD-MBD-097 Foreground color’ } {[0.3120]}
{‘STD-MBD-092 Outport Color’ } {[0.0805]} {‘STD-MBD-092 Outport Color’ } {[0.2048]}
{["STD-MBD-100 Name Display" ]} {[0.0272]} {["STD-MBD-100 Name Display" ]} {[0.0575]}
{‘STD-MBD-164 MATLAB Functions Prohibited’ } {[0.0162]} {‘STD-MBD-164 MATLAB Functions Pr…’} {[0.0283]}I am working on an Azure Pipeline. I need to echo the script output to the pipeline, and check the output to see if the stage failed. My current PowerShell code looks like this.
$cur_dir = $Env:AGENT_BUILDDIRECTORY
$log_file = Join-Path $cur_dir ‘log_file.txt’
$cmd = Join-Path $cur_dir ‘basemodeling_toolsmatlabstupid_permissions_workaround.m’
Write-Host $cmd
$args = "-logfile $log_file -nodisplay -nosplash -r run(‘$cmd’); exit();"
Start-Process matlab -ArgumentList $args -Wait
Get-Content $log_file | Write-Host
if ($log_file -match ‘TOTAL NUMBER OF FAILED BLOCKS:: 0’){
$rv = 0
}
The output saved in log_file.txt does not match the output when I run the script in Matlab. The output captured in log_file.txt is getting truncated, and I have no idea why. Is there a better way to capture the output than using the -logfile option?
Output when run inside MATLAB Output in log_file.txt
‘TOTAL NUMBER OF FAILED BLOCKS:: 38’ ‘TOTAL NUMBER OF FAILED BLOCKS:: 38’
{‘Check Name’ } {‘Time’ } {‘Check Name’ } {‘Time’ }
{["STD-MBD-098 Top Level Model" ]} {[1.1502]} {["STD-MBD-098 Top Level Model" ]} {[2.1924]}
{‘STD-MBD-122 Sample Time’ } {[0.1825]} {‘STD-MBD-122 Sample Time’ } {[0.3057]}
{‘STD-MBD-065 Relational Blocks’ } {[2.0332]} {‘STD-MBD-065 Relational Blocks’ } {[3.6043]}
{‘STD-MBD-163 Nested States Standard’ } {[0.0032]} {‘STD-MBD-163 Nested States Stand…’} {[0.0089]}
{‘STD-MBD-108 States Entry: During: Exit:’ } {[0.0198]} {‘STD-MBD-108 States Entry: Durin…’} {[0.0413]}
{‘STD-MBD-097 Foreground color’ } {[0.1659]} {‘STD-MBD-097 Foreground color’ } {[0.3120]}
{‘STD-MBD-092 Outport Color’ } {[0.0805]} {‘STD-MBD-092 Outport Color’ } {[0.2048]}
{["STD-MBD-100 Name Display" ]} {[0.0272]} {["STD-MBD-100 Name Display" ]} {[0.0575]}
{‘STD-MBD-164 MATLAB Functions Prohibited’ } {[0.0162]} {‘STD-MBD-164 MATLAB Functions Pr…’} {[0.0283]} I am working on an Azure Pipeline. I need to echo the script output to the pipeline, and check the output to see if the stage failed. My current PowerShell code looks like this.
$cur_dir = $Env:AGENT_BUILDDIRECTORY
$log_file = Join-Path $cur_dir ‘log_file.txt’
$cmd = Join-Path $cur_dir ‘basemodeling_toolsmatlabstupid_permissions_workaround.m’
Write-Host $cmd
$args = "-logfile $log_file -nodisplay -nosplash -r run(‘$cmd’); exit();"
Start-Process matlab -ArgumentList $args -Wait
Get-Content $log_file | Write-Host
if ($log_file -match ‘TOTAL NUMBER OF FAILED BLOCKS:: 0’){
$rv = 0
}
The output saved in log_file.txt does not match the output when I run the script in Matlab. The output captured in log_file.txt is getting truncated, and I have no idea why. Is there a better way to capture the output than using the -logfile option?
Output when run inside MATLAB Output in log_file.txt
‘TOTAL NUMBER OF FAILED BLOCKS:: 38’ ‘TOTAL NUMBER OF FAILED BLOCKS:: 38’
{‘Check Name’ } {‘Time’ } {‘Check Name’ } {‘Time’ }
{["STD-MBD-098 Top Level Model" ]} {[1.1502]} {["STD-MBD-098 Top Level Model" ]} {[2.1924]}
{‘STD-MBD-122 Sample Time’ } {[0.1825]} {‘STD-MBD-122 Sample Time’ } {[0.3057]}
{‘STD-MBD-065 Relational Blocks’ } {[2.0332]} {‘STD-MBD-065 Relational Blocks’ } {[3.6043]}
{‘STD-MBD-163 Nested States Standard’ } {[0.0032]} {‘STD-MBD-163 Nested States Stand…’} {[0.0089]}
{‘STD-MBD-108 States Entry: During: Exit:’ } {[0.0198]} {‘STD-MBD-108 States Entry: Durin…’} {[0.0413]}
{‘STD-MBD-097 Foreground color’ } {[0.1659]} {‘STD-MBD-097 Foreground color’ } {[0.3120]}
{‘STD-MBD-092 Outport Color’ } {[0.0805]} {‘STD-MBD-092 Outport Color’ } {[0.2048]}
{["STD-MBD-100 Name Display" ]} {[0.0272]} {["STD-MBD-100 Name Display" ]} {[0.0575]}
{‘STD-MBD-164 MATLAB Functions Prohibited’ } {[0.0162]} {‘STD-MBD-164 MATLAB Functions Pr…’} {[0.0283]} logfile, command line, terminal MATLAB Answers — New Questions
vector conversion from a vector of numbers to a vector cell of chars.
Hello,
In MATLAB I have this vector: Y=[0 4 6] and I need to convert it to this format X={‘0’ ‘4’ ‘6’}.
Not sure how to do it.
Thank youHello,
In MATLAB I have this vector: Y=[0 4 6] and I need to convert it to this format X={‘0’ ‘4’ ‘6’}.
Not sure how to do it.
Thank you Hello,
In MATLAB I have this vector: Y=[0 4 6] and I need to convert it to this format X={‘0’ ‘4’ ‘6’}.
Not sure how to do it.
Thank you format conversion, array MATLAB Answers — New Questions
Merging Mathworks accounts from previous account to current account
That is now 2 years that I left my previous emplyer and my account was associated with an email address I do not have access anymore.
I have recreated my current account with my current employement email address. How can I merge both accounts so that I keep track of the previous feeds and discussions?That is now 2 years that I left my previous emplyer and my account was associated with an email address I do not have access anymore.
I have recreated my current account with my current employement email address. How can I merge both accounts so that I keep track of the previous feeds and discussions? That is now 2 years that I left my previous emplyer and my account was associated with an email address I do not have access anymore.
I have recreated my current account with my current employement email address. How can I merge both accounts so that I keep track of the previous feeds and discussions? account MATLAB Answers — New Questions
Different X axis location. Unsure Why.
I am performing two very similar plots but the placement of the xlabel is different and I cant determine why or how to rectify it. I would prefer to force the xlabel to be as in my first example:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Pfile.csv");
%converting data
shift = table2array(Raman(:,1));
MW0 = table2array(Raman(:,2));
AlMW25 = table2array(Raman(:,3));
AlMW5 = table2array(Raman(:,4));
%plotting MW0
plot(shift, MW0)
hold on %plotting on same graph
plot(shift, AlMW25)
plot(shift, AlMW5)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
%labelling graph
xlabel("Raman Shift [cm^{-1}]");
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra")
legend("MW 0","AlMW 2.5","AlMW 5","Location","north west")
This returns the following graph:
In example two i get the following:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Ufile5.csv");
%converting data
shift0 = table2array(Raman(:,1));
NBS0 = table2array(Raman(:,2));
shift1 = table2array(Raman(:,3));
NBS1 = table2array(Raman(:,4));
shift2 = table2array(Raman(:,5));
NBS2 = table2array(Raman(:,6));
shift3 = table2array(Raman(:,7));
NBS3 = table2array(Raman(:,8));
shift4 = table2array(Raman(:,9));
NBS4 = table2array(Raman(:,10));
%plotting NBS0
plot(shift0, NBS0)
hold on %plotting on same graph
plot(shift1, NBS1)
plot(shift2, NBS2)
plot(shift3, NBS3)
plot(shift4, NBS4)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
xlabel("Raman Shift [cm^{-1}]"); % Store handle
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra for NBS Glasses");
legend("NBS 0", "NBS 1", "NBS 2", "NBS 3", "NBS 4", "Location", "northwest");
and i get the followign less optimal xlabel position:I am performing two very similar plots but the placement of the xlabel is different and I cant determine why or how to rectify it. I would prefer to force the xlabel to be as in my first example:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Pfile.csv");
%converting data
shift = table2array(Raman(:,1));
MW0 = table2array(Raman(:,2));
AlMW25 = table2array(Raman(:,3));
AlMW5 = table2array(Raman(:,4));
%plotting MW0
plot(shift, MW0)
hold on %plotting on same graph
plot(shift, AlMW25)
plot(shift, AlMW5)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
%labelling graph
xlabel("Raman Shift [cm^{-1}]");
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra")
legend("MW 0","AlMW 2.5","AlMW 5","Location","north west")
This returns the following graph:
In example two i get the following:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Ufile5.csv");
%converting data
shift0 = table2array(Raman(:,1));
NBS0 = table2array(Raman(:,2));
shift1 = table2array(Raman(:,3));
NBS1 = table2array(Raman(:,4));
shift2 = table2array(Raman(:,5));
NBS2 = table2array(Raman(:,6));
shift3 = table2array(Raman(:,7));
NBS3 = table2array(Raman(:,8));
shift4 = table2array(Raman(:,9));
NBS4 = table2array(Raman(:,10));
%plotting NBS0
plot(shift0, NBS0)
hold on %plotting on same graph
plot(shift1, NBS1)
plot(shift2, NBS2)
plot(shift3, NBS3)
plot(shift4, NBS4)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
xlabel("Raman Shift [cm^{-1}]"); % Store handle
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra for NBS Glasses");
legend("NBS 0", "NBS 1", "NBS 2", "NBS 3", "NBS 4", "Location", "northwest");
and i get the followign less optimal xlabel position: I am performing two very similar plots but the placement of the xlabel is different and I cant determine why or how to rectify it. I would prefer to force the xlabel to be as in my first example:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Pfile.csv");
%converting data
shift = table2array(Raman(:,1));
MW0 = table2array(Raman(:,2));
AlMW25 = table2array(Raman(:,3));
AlMW5 = table2array(Raman(:,4));
%plotting MW0
plot(shift, MW0)
hold on %plotting on same graph
plot(shift, AlMW25)
plot(shift, AlMW5)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
%labelling graph
xlabel("Raman Shift [cm^{-1}]");
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra")
legend("MW 0","AlMW 2.5","AlMW 5","Location","north west")
This returns the following graph:
In example two i get the following:
%clearing crap
clear all
clf
%selecting amazing font
set(0, "DefaultAxesFontName", "Courier New");
set(0, "DefaultTextFontName", "Courier New");
%importing required data
%importing data
Raman = readtable("Ufile5.csv");
%converting data
shift0 = table2array(Raman(:,1));
NBS0 = table2array(Raman(:,2));
shift1 = table2array(Raman(:,3));
NBS1 = table2array(Raman(:,4));
shift2 = table2array(Raman(:,5));
NBS2 = table2array(Raman(:,6));
shift3 = table2array(Raman(:,7));
NBS3 = table2array(Raman(:,8));
shift4 = table2array(Raman(:,9));
NBS4 = table2array(Raman(:,10));
%plotting NBS0
plot(shift0, NBS0)
hold on %plotting on same graph
plot(shift1, NBS1)
plot(shift2, NBS2)
plot(shift3, NBS3)
plot(shift4, NBS4)
hold off %end of plotting
%beautifying curve
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
box off;
xlabel("Raman Shift [cm^{-1}]"); % Store handle
ylabel("Intensity [Arb. Units.]");
title("Raman Spectra for NBS Glasses");
legend("NBS 0", "NBS 1", "NBS 2", "NBS 3", "NBS 4", "Location", "northwest");
and i get the followign less optimal xlabel position: plot, xlabel MATLAB Answers — New Questions
input Matlab table columns to excel formula and perform iteration calculation
I have two matlab tables called meandiretcion (image1) and meanspeed (image2). I also have a excel file with formula (image3), the excel formula file has 3 sheet (sheet1, sheet2, sheet3).
The aim is to perform iterative calculation on excel formula file using the value from two matlab tables.
For example, column1 of meandirection will be input to sheet1.columnF, column1 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved.
And then column2 of meandirection will be input to sheet1.columnF, column2 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved.
And then column3 of meandirection will be input to sheet1.columnF, column3 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved…
How do I perform this automatic task with Matlab?I have two matlab tables called meandiretcion (image1) and meanspeed (image2). I also have a excel file with formula (image3), the excel formula file has 3 sheet (sheet1, sheet2, sheet3).
The aim is to perform iterative calculation on excel formula file using the value from two matlab tables.
For example, column1 of meandirection will be input to sheet1.columnF, column1 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved.
And then column2 of meandirection will be input to sheet1.columnF, column2 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved.
And then column3 of meandirection will be input to sheet1.columnF, column3 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved…
How do I perform this automatic task with Matlab? I have two matlab tables called meandiretcion (image1) and meanspeed (image2). I also have a excel file with formula (image3), the excel formula file has 3 sheet (sheet1, sheet2, sheet3).
The aim is to perform iterative calculation on excel formula file using the value from two matlab tables.
For example, column1 of meandirection will be input to sheet1.columnF, column1 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved.
And then column2 of meandirection will be input to sheet1.columnF, column2 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved.
And then column3 of meandirection will be input to sheet1.columnF, column3 of meanspeed will be input to sheet2.columnM, results from sheet 3.columnP will be saved…
How do I perform this automatic task with Matlab? matlab, excel, iteration MATLAB Answers — New Questions
OPA Gatekeeper Bypass Reveals Risks in Kubernetes Policy Engines
Implementing Kubernetes securely can be a daunting task. Fortunately, there are tools in the K8s toolshed that provide out-of-the-box solutions using a single click. One such tools is OPA Gatekeeper. It is a great out-of-the-box security checkpoint to enforce security policies on Kubernetes. But are users using it correctly? Do they understand its limitations? Our new research says not necessarily!
Implementing Kubernetes securely can be a daunting task. Fortunately, there are tools in the K8s toolshed that provide out-of-the-box solutions using a single click. One such tools is OPA Gatekeeper. It is a great out-of-the-box security checkpoint to enforce security policies on Kubernetes. But are users using it correctly? Do they understand its limitations? Our new research says not necessarily!
Read More
time lag where the phase of the signals is not consistent
I have two time series where I have used xcorr to calculate the lag between two signals. However, I am sure that the time lag will not be consistently over the course of the time series. Is there a way to do a moving window time lag or another way to compute how this lag varies through time?
t = TO(:,1);
O1 = TO(:,2);
S1 = TO(:,3);
r = corr(O1,S1)
dt = mean(diff(t));
O1 = O1 – mean(O1);
S1 = S1 – mean(S1);
[c, lags] = xcorr(S1, O1);
lags = lags*dt;
[~, id]= max(abs(c))
ans = lags(id)
figure(1)
plot(lags,c)I have two time series where I have used xcorr to calculate the lag between two signals. However, I am sure that the time lag will not be consistently over the course of the time series. Is there a way to do a moving window time lag or another way to compute how this lag varies through time?
t = TO(:,1);
O1 = TO(:,2);
S1 = TO(:,3);
r = corr(O1,S1)
dt = mean(diff(t));
O1 = O1 – mean(O1);
S1 = S1 – mean(S1);
[c, lags] = xcorr(S1, O1);
lags = lags*dt;
[~, id]= max(abs(c))
ans = lags(id)
figure(1)
plot(lags,c) I have two time series where I have used xcorr to calculate the lag between two signals. However, I am sure that the time lag will not be consistently over the course of the time series. Is there a way to do a moving window time lag or another way to compute how this lag varies through time?
t = TO(:,1);
O1 = TO(:,2);
S1 = TO(:,3);
r = corr(O1,S1)
dt = mean(diff(t));
O1 = O1 – mean(O1);
S1 = S1 – mean(S1);
[c, lags] = xcorr(S1, O1);
lags = lags*dt;
[~, id]= max(abs(c))
ans = lags(id)
figure(1)
plot(lags,c) xcorr, lag, timeseries MATLAB Answers — New Questions
Interact with Heatmap embedded in a scrollable UI Panel
I knew how we can click into a Heatmap cell and get its row and column info. This can be done by comparing the mouse-clicking position vs the Heatmap position. But what if my Heatmap has many rows such that when it is created inside a UI panel, the panel becomes scrollable, say the mouse position when I click row 2 is the same as the position when I scroll down and click row 22? Is there a way to get the correct row and column index when I click on a cell after scrolling down?
I’m currently using the "heatmap" function to generate the heatmap. But if above can only be realized using other methods when creating heatmap, feel free to suggest (though my preferred way is to use the "heatmap" function as it gives better flexibility and functionality with the actual heatmap)I knew how we can click into a Heatmap cell and get its row and column info. This can be done by comparing the mouse-clicking position vs the Heatmap position. But what if my Heatmap has many rows such that when it is created inside a UI panel, the panel becomes scrollable, say the mouse position when I click row 2 is the same as the position when I scroll down and click row 22? Is there a way to get the correct row and column index when I click on a cell after scrolling down?
I’m currently using the "heatmap" function to generate the heatmap. But if above can only be realized using other methods when creating heatmap, feel free to suggest (though my preferred way is to use the "heatmap" function as it gives better flexibility and functionality with the actual heatmap) I knew how we can click into a Heatmap cell and get its row and column info. This can be done by comparing the mouse-clicking position vs the Heatmap position. But what if my Heatmap has many rows such that when it is created inside a UI panel, the panel becomes scrollable, say the mouse position when I click row 2 is the same as the position when I scroll down and click row 22? Is there a way to get the correct row and column index when I click on a cell after scrolling down?
I’m currently using the "heatmap" function to generate the heatmap. But if above can only be realized using other methods when creating heatmap, feel free to suggest (though my preferred way is to use the "heatmap" function as it gives better flexibility and functionality with the actual heatmap) appdesigner, 2024a, heatmap, uipanel MATLAB Answers — New Questions
Matlab sparse matrix does not come out as I would expect
This is my code:
S=sparse([1 3 2 1 4],[3 1 4 1 4],[1 2 3 4 5],4,4)
full(s)
However, when I run it, I get:
‘S =
(1,1) 4
(3,1) 2
(1,3) 1
(2,4) 3
(4,4) 5
ans=
0 0 0 1
0 1 0 0
1 2 0 0
0 0 3 0′
Please tell me why ans is not [4 0 1 0;0 0 0 3; 2 0 0 0; 0 0 0 5]?This is my code:
S=sparse([1 3 2 1 4],[3 1 4 1 4],[1 2 3 4 5],4,4)
full(s)
However, when I run it, I get:
‘S =
(1,1) 4
(3,1) 2
(1,3) 1
(2,4) 3
(4,4) 5
ans=
0 0 0 1
0 1 0 0
1 2 0 0
0 0 3 0′
Please tell me why ans is not [4 0 1 0;0 0 0 3; 2 0 0 0; 0 0 0 5]? This is my code:
S=sparse([1 3 2 1 4],[3 1 4 1 4],[1 2 3 4 5],4,4)
full(s)
However, when I run it, I get:
‘S =
(1,1) 4
(3,1) 2
(1,3) 1
(2,4) 3
(4,4) 5
ans=
0 0 0 1
0 1 0 0
1 2 0 0
0 0 3 0′
Please tell me why ans is not [4 0 1 0;0 0 0 3; 2 0 0 0; 0 0 0 5]? matlab MATLAB Answers — New Questions
“readmatirx” does not read the expected data?
My data is 1×51 size in csv, when I use readmatrix function to specify "Range" to import 1 to 50 data, it is empty, or import other range data, the result is all data, my sample code is as follows, thanks in advance! (The "T2.csv" is in the attachment)
T2 = readmatrix("T2.csv","Range","B1:AY1") % empty ???
T2 =
[]
T2 = readmatrix("T2.csv","Range","A1:E1") % all data is imported ???
T2 =
Columns 1 through 12
0 1.0000 0.7382 0.5086 0.3818 0.3015 0.2462 0.2058 0.1750 0.1509 0.1316 0.1157
Columns 13 through 24
0.1025 0.0914 0.0819 0.0736 0.0665 0.0602 0.0547 0.0498 0.0454 0.0415 0.0380 0.0347
Columns 25 through 36
0.0318 0.0292 0.0267 0.0245 0.0225 0.0206 0.0188 0.0172 0.0157 0.0143 0.0130 0.0117
Columns 37 through 48
0.0106 0.0095 0.0085 0.0076 0.0067 0.0058 0.0050 0.0043 0.0036 0.0029 0.0023 0.0016
Columns 49 through 51
0.0011 0.0005 0
T2 = readmatrix("T2.csv","Range","B1:E1") % also empty ???
T2 =
[]
The results of the above experiment are very strange, but the import of data from "range" using the "xlsread" function is normalMy data is 1×51 size in csv, when I use readmatrix function to specify "Range" to import 1 to 50 data, it is empty, or import other range data, the result is all data, my sample code is as follows, thanks in advance! (The "T2.csv" is in the attachment)
T2 = readmatrix("T2.csv","Range","B1:AY1") % empty ???
T2 =
[]
T2 = readmatrix("T2.csv","Range","A1:E1") % all data is imported ???
T2 =
Columns 1 through 12
0 1.0000 0.7382 0.5086 0.3818 0.3015 0.2462 0.2058 0.1750 0.1509 0.1316 0.1157
Columns 13 through 24
0.1025 0.0914 0.0819 0.0736 0.0665 0.0602 0.0547 0.0498 0.0454 0.0415 0.0380 0.0347
Columns 25 through 36
0.0318 0.0292 0.0267 0.0245 0.0225 0.0206 0.0188 0.0172 0.0157 0.0143 0.0130 0.0117
Columns 37 through 48
0.0106 0.0095 0.0085 0.0076 0.0067 0.0058 0.0050 0.0043 0.0036 0.0029 0.0023 0.0016
Columns 49 through 51
0.0011 0.0005 0
T2 = readmatrix("T2.csv","Range","B1:E1") % also empty ???
T2 =
[]
The results of the above experiment are very strange, but the import of data from "range" using the "xlsread" function is normal My data is 1×51 size in csv, when I use readmatrix function to specify "Range" to import 1 to 50 data, it is empty, or import other range data, the result is all data, my sample code is as follows, thanks in advance! (The "T2.csv" is in the attachment)
T2 = readmatrix("T2.csv","Range","B1:AY1") % empty ???
T2 =
[]
T2 = readmatrix("T2.csv","Range","A1:E1") % all data is imported ???
T2 =
Columns 1 through 12
0 1.0000 0.7382 0.5086 0.3818 0.3015 0.2462 0.2058 0.1750 0.1509 0.1316 0.1157
Columns 13 through 24
0.1025 0.0914 0.0819 0.0736 0.0665 0.0602 0.0547 0.0498 0.0454 0.0415 0.0380 0.0347
Columns 25 through 36
0.0318 0.0292 0.0267 0.0245 0.0225 0.0206 0.0188 0.0172 0.0157 0.0143 0.0130 0.0117
Columns 37 through 48
0.0106 0.0095 0.0085 0.0076 0.0067 0.0058 0.0050 0.0043 0.0036 0.0029 0.0023 0.0016
Columns 49 through 51
0.0011 0.0005 0
T2 = readmatrix("T2.csv","Range","B1:E1") % also empty ???
T2 =
[]
The results of the above experiment are very strange, but the import of data from "range" using the "xlsread" function is normal data import, csv data, readmatrix MATLAB Answers — New Questions