Category: Matlab
Category Archives: Matlab
Returning workspace outputs is supported with only single return argument
Dear,
I am trying to run a simulink model in m-code while optimizing ADRC parameters with PSO, but I get an error:
‘Returning workspace outputs is supported with only single return argument’.
The first figure is ‘PSO_ADRC’ code and the second figure is the simulink model ‘ADRC_test’.
Hope someone can help me, thanks.Dear,
I am trying to run a simulink model in m-code while optimizing ADRC parameters with PSO, but I get an error:
‘Returning workspace outputs is supported with only single return argument’.
The first figure is ‘PSO_ADRC’ code and the second figure is the simulink model ‘ADRC_test’.
Hope someone can help me, thanks. Dear,
I am trying to run a simulink model in m-code while optimizing ADRC parameters with PSO, but I get an error:
‘Returning workspace outputs is supported with only single return argument’.
The first figure is ‘PSO_ADRC’ code and the second figure is the simulink model ‘ADRC_test’.
Hope someone can help me, thanks. simulink, matlab MATLAB Answers — New Questions
zipping empty subdirectories
I try to zip a directory which contains empty sub-directories but zip() function ignore the empty ones. Is there way to include the empty subdirectories as well?I try to zip a directory which contains empty sub-directories but zip() function ignore the empty ones. Is there way to include the empty subdirectories as well? I try to zip a directory which contains empty sub-directories but zip() function ignore the empty ones. Is there way to include the empty subdirectories as well? zip MATLAB Answers — New Questions
Solve integral in nested function
hello there,
i am trying to build something like this:
if true
function x = first
x = 5*y
function y = nested
I = @(x) x^2
y = integral(I,0,1)
end
end
end
but there occurs an error stating: ‘Error: Function definitions are not permitted in this context.’
Does anyone know an alternative or sees the misstake i made?
thanks!hello there,
i am trying to build something like this:
if true
function x = first
x = 5*y
function y = nested
I = @(x) x^2
y = integral(I,0,1)
end
end
end
but there occurs an error stating: ‘Error: Function definitions are not permitted in this context.’
Does anyone know an alternative or sees the misstake i made?
thanks! hello there,
i am trying to build something like this:
if true
function x = first
x = 5*y
function y = nested
I = @(x) x^2
y = integral(I,0,1)
end
end
end
but there occurs an error stating: ‘Error: Function definitions are not permitted in this context.’
Does anyone know an alternative or sees the misstake i made?
thanks! integral, nested functions, passing results MATLAB Answers — New Questions
SIMULINK: Set a random seed in the Block Parameters: Random Number GUI
SIMULINK
How do I set a random seed in the user GUI for a random number block? (So I get a random number at each sim run)
ThanksSIMULINK
How do I set a random seed in the user GUI for a random number block? (So I get a random number at each sim run)
Thanks SIMULINK
How do I set a random seed in the user GUI for a random number block? (So I get a random number at each sim run)
Thanks simulink, random number generator MATLAB Answers — New Questions
How do I merge vectors?
I have a 10X1 vector A=[1;3;7;10;12;14;15;18;20;21] and a 10X1 vector B=[3;12;15;18;20;0;0;0;0;0]. Is there a way to come up with a 10X2 vector C such that the equal elements in each vector sit at the same row in vector C? I want to retain all elements of vector A in vector C and keep only the elements from vector B that have values equal to the one elements in vector A. Ideally, My final vector C would look something like this:
C=[1 0;3 3;7 0;10 0;12 12;14 0;15 15;18 18;20 20;21 0]. Any thoughts?I have a 10X1 vector A=[1;3;7;10;12;14;15;18;20;21] and a 10X1 vector B=[3;12;15;18;20;0;0;0;0;0]. Is there a way to come up with a 10X2 vector C such that the equal elements in each vector sit at the same row in vector C? I want to retain all elements of vector A in vector C and keep only the elements from vector B that have values equal to the one elements in vector A. Ideally, My final vector C would look something like this:
C=[1 0;3 3;7 0;10 0;12 12;14 0;15 15;18 18;20 20;21 0]. Any thoughts? I have a 10X1 vector A=[1;3;7;10;12;14;15;18;20;21] and a 10X1 vector B=[3;12;15;18;20;0;0;0;0;0]. Is there a way to come up with a 10X2 vector C such that the equal elements in each vector sit at the same row in vector C? I want to retain all elements of vector A in vector C and keep only the elements from vector B that have values equal to the one elements in vector A. Ideally, My final vector C would look something like this:
C=[1 0;3 3;7 0;10 0;12 12;14 0;15 15;18 18;20 20;21 0]. Any thoughts? merging vectors MATLAB Answers — New Questions
Can you explain the difference between the two matrix operations in MATLAB?
I am trying to understand how MATLAB performs the following matrix operations:
Example 1:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/2:Nx/2-1);
Vector1 = (sin( Vec * dx/2)/(dx/2)).^2 ;
[Matrix2,x] = cheb(Ny);
for m = 1:length(Vec)
Matrix1 = -1 * (Vector1(m))+ Matrix2;
end
Example 2:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/2:Nx/2-1);
Vector1 = (sin( Vec * dx/2)/(dx/2)).^2 ;
Igl = speye(Ny+1);
[Matrix2,x] = cheb(Ny);
for m = 1:length(Vec)
Matrix1 = -Igl * (Vector1(m))+ Matrix2;
end
Why is Matrix1 different in Example1 and Example 2? In particular, in Example 1 how is the scalar multiplication of the row vector (Vector1(m)) added to Matrix 2? I am trying to understand the matrix operation done in Example 1 specifically so I can transfer it to C/C++. ThanksI am trying to understand how MATLAB performs the following matrix operations:
Example 1:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/2:Nx/2-1);
Vector1 = (sin( Vec * dx/2)/(dx/2)).^2 ;
[Matrix2,x] = cheb(Ny);
for m = 1:length(Vec)
Matrix1 = -1 * (Vector1(m))+ Matrix2;
end
Example 2:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/2:Nx/2-1);
Vector1 = (sin( Vec * dx/2)/(dx/2)).^2 ;
Igl = speye(Ny+1);
[Matrix2,x] = cheb(Ny);
for m = 1:length(Vec)
Matrix1 = -Igl * (Vector1(m))+ Matrix2;
end
Why is Matrix1 different in Example1 and Example 2? In particular, in Example 1 how is the scalar multiplication of the row vector (Vector1(m)) added to Matrix 2? I am trying to understand the matrix operation done in Example 1 specifically so I can transfer it to C/C++. Thanks I am trying to understand how MATLAB performs the following matrix operations:
Example 1:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/2:Nx/2-1);
Vector1 = (sin( Vec * dx/2)/(dx/2)).^2 ;
[Matrix2,x] = cheb(Ny);
for m = 1:length(Vec)
Matrix1 = -1 * (Vector1(m))+ Matrix2;
end
Example 2:
clearvars; clc; close all;
Nx = 8;
Ny = 8;
Lx=2*pi;
dx = Lx/Nx;
Vec = fftshift(-Nx/2:Nx/2-1);
Vector1 = (sin( Vec * dx/2)/(dx/2)).^2 ;
Igl = speye(Ny+1);
[Matrix2,x] = cheb(Ny);
for m = 1:length(Vec)
Matrix1 = -Igl * (Vector1(m))+ Matrix2;
end
Why is Matrix1 different in Example1 and Example 2? In particular, in Example 1 how is the scalar multiplication of the row vector (Vector1(m)) added to Matrix 2? I am trying to understand the matrix operation done in Example 1 specifically so I can transfer it to C/C++. Thanks matrix MATLAB Answers — New Questions
how to find connected component in an image
i’m doing a project to recognize kannada text,the first step says find connected components from a binarynimage.i tried doing it using bwconncomp but i’m not able to display the image.soo can u please help me with dis.i’m doing a project to recognize kannada text,the first step says find connected components from a binarynimage.i tried doing it using bwconncomp but i’m not able to display the image.soo can u please help me with dis. i’m doing a project to recognize kannada text,the first step says find connected components from a binarynimage.i tried doing it using bwconncomp but i’m not able to display the image.soo can u please help me with dis. ocr, kannada, image segmentation, connected components MATLAB Answers — New Questions
I am running external mode on arduino mega and the analog inputs are always high. What is wrong in my settings?
I am trying to run external mode and read an Analog Input on an Arduino Mega. I always see the input set to high (5) no mater what my actual voltage is. I just convert the analog input to read between 0-5V (5/1023), but there is no other response. It’s always stuch in high. All Analog outputs are working properly, but I cannot fix my input readings. Is there a setting that I have to change? What am I doing wrong? TIAI am trying to run external mode and read an Analog Input on an Arduino Mega. I always see the input set to high (5) no mater what my actual voltage is. I just convert the analog input to read between 0-5V (5/1023), but there is no other response. It’s always stuch in high. All Analog outputs are working properly, but I cannot fix my input readings. Is there a setting that I have to change? What am I doing wrong? TIA I am trying to run external mode and read an Analog Input on an Arduino Mega. I always see the input set to high (5) no mater what my actual voltage is. I just convert the analog input to read between 0-5V (5/1023), but there is no other response. It’s always stuch in high. All Analog outputs are working properly, but I cannot fix my input readings. Is there a setting that I have to change? What am I doing wrong? TIA arduino mega, analog inputs, external mode MATLAB Answers — New Questions
LTE Turbo encoder with R = 1/2 – BER performance with LTE Toolbox
Hi there,
I am trying to make BER performance of LTE Turbo encoding with rate matching R = 1/2. But, when I implement symbol modulation and demodulation I can’t get BER = 0 (without any AWGN existence). This indicates that problem is in mod/demod part. I will be also great to use BPSK instead of QPSK but lteSymbolModulate doesn’t have this modulation scheme. Thank You in advance.
All best,
Mirza
Code: (credits to answer how-to-use-rate-matching-to-alter-turbo-code-rate)
clear;
K = 128;
E = 2*K;
mbits = randi([0,1],K, 1);
crc = lteCRCEncode(mbits,’24A’);
cbs = lteCodeBlockSegment(crc); % This will provide a length 4096 bits that is input to the Turbo encoder
cd = lteTurboEncode(cbs);
cdrm = lteRateMatchTurbo(cd, E, 0);
%cdrm(cdrm == 0) = -1; % Make them as LLRs
txSymbols = lteSymbolModulate(cdrm,’QPSK’);
awgnchan = comm.AWGNChannel(‘NoiseMethod’,’Variance’,’Variance’,3);
rxSymbols = txSymbols;% awgnchan(txSymbols);
softBits= lteSymbolDemodulate(rxSymbols,’QPSK’,’Soft’);
cdrx = lteRateRecoverTurbo(softBits, K, 0);
%
mhat = lteTurboDecode(cdrx); % So after the Turbo decoding, it will have 4096 bits rather than 4032 bits, due to addition of filler bits and CRC
cbshat = lteCodeBlockDesegment(mhat, K+24);
crchat = lteCRCDecode(cbshat,’24A’); % This will return the same as message length
% Check the decoded bits with message bits
[~,BER] = biterr( double(crchat),mbits);
BERHi there,
I am trying to make BER performance of LTE Turbo encoding with rate matching R = 1/2. But, when I implement symbol modulation and demodulation I can’t get BER = 0 (without any AWGN existence). This indicates that problem is in mod/demod part. I will be also great to use BPSK instead of QPSK but lteSymbolModulate doesn’t have this modulation scheme. Thank You in advance.
All best,
Mirza
Code: (credits to answer how-to-use-rate-matching-to-alter-turbo-code-rate)
clear;
K = 128;
E = 2*K;
mbits = randi([0,1],K, 1);
crc = lteCRCEncode(mbits,’24A’);
cbs = lteCodeBlockSegment(crc); % This will provide a length 4096 bits that is input to the Turbo encoder
cd = lteTurboEncode(cbs);
cdrm = lteRateMatchTurbo(cd, E, 0);
%cdrm(cdrm == 0) = -1; % Make them as LLRs
txSymbols = lteSymbolModulate(cdrm,’QPSK’);
awgnchan = comm.AWGNChannel(‘NoiseMethod’,’Variance’,’Variance’,3);
rxSymbols = txSymbols;% awgnchan(txSymbols);
softBits= lteSymbolDemodulate(rxSymbols,’QPSK’,’Soft’);
cdrx = lteRateRecoverTurbo(softBits, K, 0);
%
mhat = lteTurboDecode(cdrx); % So after the Turbo decoding, it will have 4096 bits rather than 4032 bits, due to addition of filler bits and CRC
cbshat = lteCodeBlockDesegment(mhat, K+24);
crchat = lteCRCDecode(cbshat,’24A’); % This will return the same as message length
% Check the decoded bits with message bits
[~,BER] = biterr( double(crchat),mbits);
BER Hi there,
I am trying to make BER performance of LTE Turbo encoding with rate matching R = 1/2. But, when I implement symbol modulation and demodulation I can’t get BER = 0 (without any AWGN existence). This indicates that problem is in mod/demod part. I will be also great to use BPSK instead of QPSK but lteSymbolModulate doesn’t have this modulation scheme. Thank You in advance.
All best,
Mirza
Code: (credits to answer how-to-use-rate-matching-to-alter-turbo-code-rate)
clear;
K = 128;
E = 2*K;
mbits = randi([0,1],K, 1);
crc = lteCRCEncode(mbits,’24A’);
cbs = lteCodeBlockSegment(crc); % This will provide a length 4096 bits that is input to the Turbo encoder
cd = lteTurboEncode(cbs);
cdrm = lteRateMatchTurbo(cd, E, 0);
%cdrm(cdrm == 0) = -1; % Make them as LLRs
txSymbols = lteSymbolModulate(cdrm,’QPSK’);
awgnchan = comm.AWGNChannel(‘NoiseMethod’,’Variance’,’Variance’,3);
rxSymbols = txSymbols;% awgnchan(txSymbols);
softBits= lteSymbolDemodulate(rxSymbols,’QPSK’,’Soft’);
cdrx = lteRateRecoverTurbo(softBits, K, 0);
%
mhat = lteTurboDecode(cdrx); % So after the Turbo decoding, it will have 4096 bits rather than 4032 bits, due to addition of filler bits and CRC
cbshat = lteCodeBlockDesegment(mhat, K+24);
crchat = lteCRCDecode(cbshat,’24A’); % This will return the same as message length
% Check the decoded bits with message bits
[~,BER] = biterr( double(crchat),mbits);
BER lte toolbox, lte rate match turbo MATLAB Answers — New Questions
For loop on .txt serie
I have a time serie mySerie.txt (1000×1).
I need to evaluate a function on consecutive subseries with increase in length, from 350 points up to 750 points.
Example: starting from latest 350 points (from 651 : 1000, first serie) I have to apply myFunction and get a result,then do the same but this time on data from 650:1000, and again from 649 : 1000 and so on up to the last iteration on 251:1000.These are 750 iterations and I will get 750 result from myFunction, saved in an array or vector in order to be plotted.Thanks for any help.I have a time serie mySerie.txt (1000×1).
I need to evaluate a function on consecutive subseries with increase in length, from 350 points up to 750 points.
Example: starting from latest 350 points (from 651 : 1000, first serie) I have to apply myFunction and get a result,then do the same but this time on data from 650:1000, and again from 649 : 1000 and so on up to the last iteration on 251:1000.These are 750 iterations and I will get 750 result from myFunction, saved in an array or vector in order to be plotted.Thanks for any help. I have a time serie mySerie.txt (1000×1).
I need to evaluate a function on consecutive subseries with increase in length, from 350 points up to 750 points.
Example: starting from latest 350 points (from 651 : 1000, first serie) I have to apply myFunction and get a result,then do the same but this time on data from 650:1000, and again from 649 : 1000 and so on up to the last iteration on 251:1000.These are 750 iterations and I will get 750 result from myFunction, saved in an array or vector in order to be plotted.Thanks for any help. for loop MATLAB Answers — New Questions
model settings- dialog box is not opening
i want to change certain settings in model – matlab- stateflow,
but i am facing errors
error:- issue while creating model configuration parameters dialog box, i have attached snipi want to change certain settings in model – matlab- stateflow,
but i am facing errors
error:- issue while creating model configuration parameters dialog box, i have attached snip i want to change certain settings in model – matlab- stateflow,
but i am facing errors
error:- issue while creating model configuration parameters dialog box, i have attached snip stateflow, matlab2022b MATLAB Answers — New Questions
how to merge tables without any common keywords?
I have a 20*20,a 20*1 and a 1*20 tables. I would like add the last two tables into the first one and become a 21*21 table. However all of the three tables are exactly numeric and do not have name for rows and columns and no common keywords.I have a 20*20,a 20*1 and a 1*20 tables. I would like add the last two tables into the first one and become a 21*21 table. However all of the three tables are exactly numeric and do not have name for rows and columns and no common keywords. I have a 20*20,a 20*1 and a 1*20 tables. I would like add the last two tables into the first one and become a 21*21 table. However all of the three tables are exactly numeric and do not have name for rows and columns and no common keywords. merge tables, add row in table, add column in table MATLAB Answers — New Questions
How to create configurable number of inputs/outputs channel.
We are working creating generic model which will have upto 10 input/output bus channels. But based on project we may need anything between 1 to 10 channels. How can we make configurable model which can select the inputs/outputs required.We are working creating generic model which will have upto 10 input/output bus channels. But based on project we may need anything between 1 to 10 channels. How can we make configurable model which can select the inputs/outputs required. We are working creating generic model which will have upto 10 input/output bus channels. But based on project we may need anything between 1 to 10 channels. How can we make configurable model which can select the inputs/outputs required. simulink, variant subsystem MATLAB Answers — New Questions
I get the illegal instruction error while running Matlab code with GPU
I get the illegal instruction error while running Matlab code with GPU.
when using matlab train networks and calculate big matrix with GPU, this error will happen.I get the illegal instruction error while running Matlab code with GPU.
when using matlab train networks and calculate big matrix with GPU, this error will happen. I get the illegal instruction error while running Matlab code with GPU.
when using matlab train networks and calculate big matrix with GPU, this error will happen. gpu MATLAB Answers — New Questions
Compiled App running extremely slow in the MATLAB runtime environment
Hello
I composed a code on Ubuntu Desktop 22.04LTS using Matlab R2024a, and it takes 236 seconds to execute.
Then i compiled it into a linux app and install Matlab runtime 2024a on the same computer (bare metal, not virtual machine, i7-6790K, 16GB RAM),
but the app executed extremely slow with the Matlab runtime, after serveral loops, its outputs seens stopped, but the thread is still running.
I didn’t using Parallel Computing Toolbox in my code.Hello
I composed a code on Ubuntu Desktop 22.04LTS using Matlab R2024a, and it takes 236 seconds to execute.
Then i compiled it into a linux app and install Matlab runtime 2024a on the same computer (bare metal, not virtual machine, i7-6790K, 16GB RAM),
but the app executed extremely slow with the Matlab runtime, after serveral loops, its outputs seens stopped, but the thread is still running.
I didn’t using Parallel Computing Toolbox in my code. Hello
I composed a code on Ubuntu Desktop 22.04LTS using Matlab R2024a, and it takes 236 seconds to execute.
Then i compiled it into a linux app and install Matlab runtime 2024a on the same computer (bare metal, not virtual machine, i7-6790K, 16GB RAM),
but the app executed extremely slow with the Matlab runtime, after serveral loops, its outputs seens stopped, but the thread is still running.
I didn’t using Parallel Computing Toolbox in my code. matlab runtime, matlab, matlab compiler MATLAB Answers — New Questions
How to fix it standalone application problem error during packaging in matlab R2014a please any have correct solution for such error
When I type command in command prompt is Error using mcc
Test checkout of feature ‘Compiler’ failed and when I convert .m file to standalone application it’s showing error and open and file log with showing error this oneWhen I type command in command prompt is Error using mcc
Test checkout of feature ‘Compiler’ failed and when I convert .m file to standalone application it’s showing error and open and file log with showing error this one When I type command in command prompt is Error using mcc
Test checkout of feature ‘Compiler’ failed and when I convert .m file to standalone application it’s showing error and open and file log with showing error this one please give me correct solution MATLAB Answers — New Questions
how to write file in PS using simulink
We are using a ZCU111 board and matlab/simulink to implement RFSoC logics. We are developing using the example on the Matlab website ( https://www.mathworks.com/help/soc/ug/ReceiveSignalWaveformUsingDDR4onXilinxRFSoCDevice.html ). There are PL and PS/processor in RFSoC. We want to create/generate data in PL and save data in PS.
Currently, a file has been created in PS. It is not the data we want, but it is writing something. However, after rebooting, it can no longer write data. Also, it is currently writing data to only one file, but we want to manage data events for multiple files. We are saving data in a set of FIFOs and are able to read it out to the computer, but we want to save this data as incrementally named files (event1, event2, etc.) on the PS system instead.
In other words, there are two questions.
Q1. How can we generate files per event in PS/processor?
Q2. How do we keep writing data to files even after a reboot in PS/processor?We are using a ZCU111 board and matlab/simulink to implement RFSoC logics. We are developing using the example on the Matlab website ( https://www.mathworks.com/help/soc/ug/ReceiveSignalWaveformUsingDDR4onXilinxRFSoCDevice.html ). There are PL and PS/processor in RFSoC. We want to create/generate data in PL and save data in PS.
Currently, a file has been created in PS. It is not the data we want, but it is writing something. However, after rebooting, it can no longer write data. Also, it is currently writing data to only one file, but we want to manage data events for multiple files. We are saving data in a set of FIFOs and are able to read it out to the computer, but we want to save this data as incrementally named files (event1, event2, etc.) on the PS system instead.
In other words, there are two questions.
Q1. How can we generate files per event in PS/processor?
Q2. How do we keep writing data to files even after a reboot in PS/processor? We are using a ZCU111 board and matlab/simulink to implement RFSoC logics. We are developing using the example on the Matlab website ( https://www.mathworks.com/help/soc/ug/ReceiveSignalWaveformUsingDDR4onXilinxRFSoCDevice.html ). There are PL and PS/processor in RFSoC. We want to create/generate data in PL and save data in PS.
Currently, a file has been created in PS. It is not the data we want, but it is writing something. However, after rebooting, it can no longer write data. Also, it is currently writing data to only one file, but we want to manage data events for multiple files. We are saving data in a set of FIFOs and are able to read it out to the computer, but we want to save this data as incrementally named files (event1, event2, etc.) on the PS system instead.
In other words, there are two questions.
Q1. How can we generate files per event in PS/processor?
Q2. How do we keep writing data to files even after a reboot in PS/processor? write file in ps/processor MATLAB Answers — New Questions
How to evaluate if my design/matlab code/algorithm can be dumped in controller or processor or fpga or gpu?
I would like to know how can I see what can i use for my application for example:
i am trying to do take image and do the segmentation using blob analysis to identify a object in an image or video. how to determine whether i would need a controller or microprocessor or fpga or gpu ?I would like to know how can I see what can i use for my application for example:
i am trying to do take image and do the segmentation using blob analysis to identify a object in an image or video. how to determine whether i would need a controller or microprocessor or fpga or gpu ? I would like to know how can I see what can i use for my application for example:
i am trying to do take image and do the segmentation using blob analysis to identify a object in an image or video. how to determine whether i would need a controller or microprocessor or fpga or gpu ? fpga, gpu, controller, processor MATLAB Answers — New Questions
How to put parameters in pv array?
Hello,
How can I put these parametrs do this pv array in simulink?Hello,
How can I put these parametrs do this pv array in simulink? Hello,
How can I put these parametrs do this pv array in simulink? arrays, matlab, simulink MATLAB Answers — New Questions
Is there a quick function to make an array whose elements are the sum of the row and column numbers?
Hello! This should hopefully be a quick and easy question:
Is there a function such that the output of Fun(4) would be:
[2 3 4 5;
3 4 5 6;
4 5 6 7;
5 6 7 8]
i.e. each element of the matrix is equal to its row number + its column number?
I cannot figure out a way to search this question in a concise manner, so I haven’t been able to find anything. I know this is fairly simple to code, but I’m curious if there’s an already existing function for this. Thanks!Hello! This should hopefully be a quick and easy question:
Is there a function such that the output of Fun(4) would be:
[2 3 4 5;
3 4 5 6;
4 5 6 7;
5 6 7 8]
i.e. each element of the matrix is equal to its row number + its column number?
I cannot figure out a way to search this question in a concise manner, so I haven’t been able to find anything. I know this is fairly simple to code, but I’m curious if there’s an already existing function for this. Thanks! Hello! This should hopefully be a quick and easy question:
Is there a function such that the output of Fun(4) would be:
[2 3 4 5;
3 4 5 6;
4 5 6 7;
5 6 7 8]
i.e. each element of the matrix is equal to its row number + its column number?
I cannot figure out a way to search this question in a concise manner, so I haven’t been able to find anything. I know this is fairly simple to code, but I’m curious if there’s an already existing function for this. Thanks! arrays, sum MATLAB Answers — New Questions