Category: News
Output problem for If – statement in For – Loop
This is a part of my code:
answerCoordinates = [238, 285; 152, 130; 108, 565; 489, 557; 238, 287; 289, 557; 530, 335];
for i = 1:size(answerCoordinates, 1)
answerX = answerCoordinates(i, 1);
answerY = answerCoordinates(i, 2);
if x >= (answerX – 25) && x <= (answerX + 25) && y >= (answerY – 25) && y <= (answerY + 25)
fprintf("You have found a new spot! n");
fprintf("Current Progress: %d/5 n",currentLoop)
currentLoop = currentLoop + 1
% else
% stopThegame = stopThegame + 1
% else
% fprintf("Ops!Wrong Spot!Start Again!")
% rect = findall(gcf,’Type’, ‘Rectangle’);
% delete(rect);
% currentLoop = 1
end
% if stopThegame ~= 7
% fprintf("Ops!Wrong Spot!Start Again!")
% rect = findall(gcf,’Type’, ‘Rectangle’);
% delete(rect);
% currentLoop = 1
% end
end
The for loop will iterate 7 times, considering there are only 7 answers. The if-statement aims to identify whether the user’s entered coordinate matches one of the answer coordinates. I’m having difficulty outputting the value when the user’s coordinate doesn’t match any of the answer coordinates. The section involving ‘%’ is my attempt to address this issue, but it hasn’t been successful so far.
How can I solve this problem?This is a part of my code:
answerCoordinates = [238, 285; 152, 130; 108, 565; 489, 557; 238, 287; 289, 557; 530, 335];
for i = 1:size(answerCoordinates, 1)
answerX = answerCoordinates(i, 1);
answerY = answerCoordinates(i, 2);
if x >= (answerX – 25) && x <= (answerX + 25) && y >= (answerY – 25) && y <= (answerY + 25)
fprintf("You have found a new spot! n");
fprintf("Current Progress: %d/5 n",currentLoop)
currentLoop = currentLoop + 1
% else
% stopThegame = stopThegame + 1
% else
% fprintf("Ops!Wrong Spot!Start Again!")
% rect = findall(gcf,’Type’, ‘Rectangle’);
% delete(rect);
% currentLoop = 1
end
% if stopThegame ~= 7
% fprintf("Ops!Wrong Spot!Start Again!")
% rect = findall(gcf,’Type’, ‘Rectangle’);
% delete(rect);
% currentLoop = 1
% end
end
The for loop will iterate 7 times, considering there are only 7 answers. The if-statement aims to identify whether the user’s entered coordinate matches one of the answer coordinates. I’m having difficulty outputting the value when the user’s coordinate doesn’t match any of the answer coordinates. The section involving ‘%’ is my attempt to address this issue, but it hasn’t been successful so far.
How can I solve this problem? This is a part of my code:
answerCoordinates = [238, 285; 152, 130; 108, 565; 489, 557; 238, 287; 289, 557; 530, 335];
for i = 1:size(answerCoordinates, 1)
answerX = answerCoordinates(i, 1);
answerY = answerCoordinates(i, 2);
if x >= (answerX – 25) && x <= (answerX + 25) && y >= (answerY – 25) && y <= (answerY + 25)
fprintf("You have found a new spot! n");
fprintf("Current Progress: %d/5 n",currentLoop)
currentLoop = currentLoop + 1
% else
% stopThegame = stopThegame + 1
% else
% fprintf("Ops!Wrong Spot!Start Again!")
% rect = findall(gcf,’Type’, ‘Rectangle’);
% delete(rect);
% currentLoop = 1
end
% if stopThegame ~= 7
% fprintf("Ops!Wrong Spot!Start Again!")
% rect = findall(gcf,’Type’, ‘Rectangle’);
% delete(rect);
% currentLoop = 1
% end
end
The for loop will iterate 7 times, considering there are only 7 answers. The if-statement aims to identify whether the user’s entered coordinate matches one of the answer coordinates. I’m having difficulty outputting the value when the user’s coordinate doesn’t match any of the answer coordinates. The section involving ‘%’ is my attempt to address this issue, but it hasn’t been successful so far.
How can I solve this problem? for loop, if statement, output MATLAB Answers — New Questions
Microsoft Apps won’t connect to internet
Microsoft apps (News, Widgets, Mail, Feedback Hub, Get Help) won’t connect to the internet, but Edge connects just fine, and Troubleshooter says there are no internet problems found. The problem started for me about the time I updated to KB5037000 (beta). I tried uninstalling the update, but it didn’t help.
Microsoft apps (News, Widgets, Mail, Feedback Hub, Get Help) won’t connect to the internet, but Edge connects just fine, and Troubleshooter says there are no internet problems found. The problem started for me about the time I updated to KB5037000 (beta). I tried uninstalling the update, but it didn’t help. Read More
Viva Amplify Issues
Hello!
I am currently doing a consulting project focused on the internal communications of a large corporation. Although Viva Amplify is a very interesting tool, the following issues prevent us from recommending the platform:
1. It does not allow audience targeting for SharePoint publications. This is a major issue.
2. It does not have a calendar of all the scheduled publications, with the channels and audiences of each one – it does not allow communicators to have a holistic view what is being communicated
3. It does not provide comprehensive analytical capabilities – it does not showcase the average time in each publication and it does not showcase the overal usage and engagement with the channels
Does anyone know of a way to solve this issues? Any extension?
@microsoft please focus on improving Viva Amplify
Hello!I am currently doing a consulting project focused on the internal communications of a large corporation. Although Viva Amplify is a very interesting tool, the following issues prevent us from recommending the platform: 1. It does not allow audience targeting for SharePoint publications. This is a major issue. 2. It does not have a calendar of all the scheduled publications, with the channels and audiences of each one – it does not allow communicators to have a holistic view what is being communicated3. It does not provide comprehensive analytical capabilities – it does not showcase the average time in each publication and it does not showcase the overal usage and engagement with the channels Does anyone know of a way to solve this issues? Any extension?@microsoft please focus on improving Viva Amplify Read More
Why the difference?
I have Edge for macOS installed on my, well, Mac.
I have two user accounts which use it as their browser.
One one of them, if I customize the home screen, I see this:
On the other, I see this:
Why are they different?
I have Edge for macOS installed on my, well, Mac.I have two user accounts which use it as their browser. One one of them, if I customize the home screen, I see this: On the other, I see this: Why are they different? Read More
automatic change in variable’s value during optimisation
I am currently working on optimising the cost of charge of an electric vehicule by scheduling a charging/discharging process during 9 intervals.
During the process an uncertainty of battery degradation occures in a specific interval, the capacity is reduced from 60ah to 58.2ah.
My question is to how to update the new value while the code is running so the optimisation algorithm performs a rescheduing based on the new value ? Thank you.I am currently working on optimising the cost of charge of an electric vehicule by scheduling a charging/discharging process during 9 intervals.
During the process an uncertainty of battery degradation occures in a specific interval, the capacity is reduced from 60ah to 58.2ah.
My question is to how to update the new value while the code is running so the optimisation algorithm performs a rescheduing based on the new value ? Thank you. I am currently working on optimising the cost of charge of an electric vehicule by scheduling a charging/discharging process during 9 intervals.
During the process an uncertainty of battery degradation occures in a specific interval, the capacity is reduced from 60ah to 58.2ah.
My question is to how to update the new value while the code is running so the optimisation algorithm performs a rescheduing based on the new value ? Thank you. variable, optimization, matlab, scheduling MATLAB Answers — New Questions
backtestEngine / runBacktest speed of execution / parallelisation
Hi Experts,
Do we know whether runBacktest (part of backtestEngine) does any parallel execution … on timatables having daily data (say, up to 10K lines), daily rebalance is "bareable" – however, the higher the table, the slower the execution. Looking at the CPU, it doesn’t look like parfor is being used at all. Basically, getting on higher time resolution, anything other than daily bars (such as hourly, minute, etc.) – it gets practically impossible to execute a runBacktest on a bar by bar rebalance, even on a very small number of tickers / instruments / timetable columns (take 20 for example, forget about taking a full index).
ThanksHi Experts,
Do we know whether runBacktest (part of backtestEngine) does any parallel execution … on timatables having daily data (say, up to 10K lines), daily rebalance is "bareable" – however, the higher the table, the slower the execution. Looking at the CPU, it doesn’t look like parfor is being used at all. Basically, getting on higher time resolution, anything other than daily bars (such as hourly, minute, etc.) – it gets practically impossible to execute a runBacktest on a bar by bar rebalance, even on a very small number of tickers / instruments / timetable columns (take 20 for example, forget about taking a full index).
Thanks Hi Experts,
Do we know whether runBacktest (part of backtestEngine) does any parallel execution … on timatables having daily data (say, up to 10K lines), daily rebalance is "bareable" – however, the higher the table, the slower the execution. Looking at the CPU, it doesn’t look like parfor is being used at all. Basically, getting on higher time resolution, anything other than daily bars (such as hourly, minute, etc.) – it gets practically impossible to execute a runBacktest on a bar by bar rebalance, even on a very small number of tickers / instruments / timetable columns (take 20 for example, forget about taking a full index).
Thanks backtestengine, runbacktest, backteststrategy, rebalancefrequency, financial toolbox, quantitative finance MATLAB Answers — New Questions
How to use boxchart and GroupByColor when having a matrix?
Dear all,
I am trying to use a boxchart for plotting a (10000,10) matrix, where each column represents a single box.
In other words, I would like to plot a boxchart consisting of 10 boxes and 10,000 data points.
The problem is that all Answers in the forum I have read so far are related to vectors, not matrices. All my attempts of using boxchart have resulted in an error, which states that I cannot use a matrix but vectors. Transforming the matrix into a vector is not possible. Additionally, I would like to group the 10 columns in 3 categories by assigning each box the respective color:
column [1 2 3 4 5 6 7 8 9 10]
group [A A B C C B A B C A]
color: [r r g b b g r g b r ]
However, I cannot provide a vector with values and tell Matlab to group the columns of the matrix on the basis of a specific threshold (e.g. temperature), but I have to do this manually by paper and pencil and inform Matlab which column belongs to which group myself.
I use the following code:
figure (2)
groupname={‘A’,’A’,’B’,’C’,’C’,’B’,’A’,’B’,’C’,’A’}’;
boxchart(AX.t_k,’MarkerStyle’, ‘none’,’GroupByColor’, groupname); % AX.t_k = (10000,10) matrix
And I get the following error:
Error using boxchart
‘GroupByColor’ parameter is not supported when the sample data argument is a matrix.
Could someone tell me, how I can use boxchart when using a matrix and how I can group each column with their respective color?
Thank you very much for your help!Dear all,
I am trying to use a boxchart for plotting a (10000,10) matrix, where each column represents a single box.
In other words, I would like to plot a boxchart consisting of 10 boxes and 10,000 data points.
The problem is that all Answers in the forum I have read so far are related to vectors, not matrices. All my attempts of using boxchart have resulted in an error, which states that I cannot use a matrix but vectors. Transforming the matrix into a vector is not possible. Additionally, I would like to group the 10 columns in 3 categories by assigning each box the respective color:
column [1 2 3 4 5 6 7 8 9 10]
group [A A B C C B A B C A]
color: [r r g b b g r g b r ]
However, I cannot provide a vector with values and tell Matlab to group the columns of the matrix on the basis of a specific threshold (e.g. temperature), but I have to do this manually by paper and pencil and inform Matlab which column belongs to which group myself.
I use the following code:
figure (2)
groupname={‘A’,’A’,’B’,’C’,’C’,’B’,’A’,’B’,’C’,’A’}’;
boxchart(AX.t_k,’MarkerStyle’, ‘none’,’GroupByColor’, groupname); % AX.t_k = (10000,10) matrix
And I get the following error:
Error using boxchart
‘GroupByColor’ parameter is not supported when the sample data argument is a matrix.
Could someone tell me, how I can use boxchart when using a matrix and how I can group each column with their respective color?
Thank you very much for your help! Dear all,
I am trying to use a boxchart for plotting a (10000,10) matrix, where each column represents a single box.
In other words, I would like to plot a boxchart consisting of 10 boxes and 10,000 data points.
The problem is that all Answers in the forum I have read so far are related to vectors, not matrices. All my attempts of using boxchart have resulted in an error, which states that I cannot use a matrix but vectors. Transforming the matrix into a vector is not possible. Additionally, I would like to group the 10 columns in 3 categories by assigning each box the respective color:
column [1 2 3 4 5 6 7 8 9 10]
group [A A B C C B A B C A]
color: [r r g b b g r g b r ]
However, I cannot provide a vector with values and tell Matlab to group the columns of the matrix on the basis of a specific threshold (e.g. temperature), but I have to do this manually by paper and pencil and inform Matlab which column belongs to which group myself.
I use the following code:
figure (2)
groupname={‘A’,’A’,’B’,’C’,’C’,’B’,’A’,’B’,’C’,’A’}’;
boxchart(AX.t_k,’MarkerStyle’, ‘none’,’GroupByColor’, groupname); % AX.t_k = (10000,10) matrix
And I get the following error:
Error using boxchart
‘GroupByColor’ parameter is not supported when the sample data argument is a matrix.
Could someone tell me, how I can use boxchart when using a matrix and how I can group each column with their respective color?
Thank you very much for your help! boxchart, matrix, color MATLAB Answers — New Questions
Power Query activity is executing but not returning and keeps loading forever
Hello,
Power query activity was working fine until last Thursday (April 18th), now whenever I run it whether by debug or manual trigger, it keeps loading forever.
The job itself is executed and the sink files are generated in Blob storage but it keeps loading without returning or moving to the following activity.
When I tested by creating the same pipeline in another Data Factory in East US 2, it worked normally. while in Data Factories in East US and US Central and Western Europe is not working.
So to summarize:
Power query executing but not returning in two different tenants in different zones (East US, US Central, and Western Europe). Yet it works on both tenants in East US 2 region.
Thanks,
Yehia
Hello,Power query activity was working fine until last Thursday (April 18th), now whenever I run it whether by debug or manual trigger, it keeps loading forever.The job itself is executed and the sink files are generated in Blob storage but it keeps loading without returning or moving to the following activity.When I tested by creating the same pipeline in another Data Factory in East US 2, it worked normally. while in Data Factories in East US and US Central and Western Europe is not working.So to summarize:Power query executing but not returning in two different tenants in different zones (East US, US Central, and Western Europe). Yet it works on both tenants in East US 2 region.Thanks,Yehia Read More
my discussion as enduser ^_^
Windows Phone Concept: A concept designer shared a video of what a Windows Phone might look like running on Windows 121. The concept includes several features you’d expect on any modern phone, including an In-display fingerprint sensor and Always-On Display technology1. The concept also showcases a mini-taskbar at the bottom of “Windows 12 mobile” which neatly packs several apps, including Microsoft Copilot1.
Surface Duo 3: There are rumors about a completely new design for the Surface Duo 3, potentially releasing in late 20242. However, these are just speculations and the project could be cancelled2.
any chance on copilot on end user terminals as native integrated ?
Youno microsoft phone on horiozon? with you on board? Windows Phone Concept: A concept designer shared a video of what a Windows Phone might look like running on Windows 121. The concept includes several features you’d expect on any modern phone, including an In-display fingerprint sensor and Always-On Display technology1. The concept also showcases a mini-taskbar at the bottom of “Windows 12 mobile” which neatly packs several apps, including Microsoft Copilot1.Surface Duo 3: There are rumors about a completely new design for the Surface Duo 3, potentially releasing in late 20242. However, these are just speculations and the project could be cancelled2.any chance on copilot on end user terminals as native integrated ? Read More
Exchange online migration using EDB tool
Hi All,
I have got a project which is half way in migration using EDB tool. I would like to know whether i can use the Exchange cutover migration for the remaining mailboxes(100+)?
I did notice accounts were created using CSV file and etc. I can remove that as well.
EDB is not user friendly tool as it will not give provide the graphical view of each mailbox sync status and etc.
Hi All, I have got a project which is half way in migration using EDB tool. I would like to know whether i can use the Exchange cutover migration for the remaining mailboxes(100+)? I did notice accounts were created using CSV file and etc. I can remove that as well. EDB is not user friendly tool as it will not give provide the graphical view of each mailbox sync status and etc. Read More
Setting up an optimization in matlab
Hi everyone.
I have an optimization problem that seeks to aid the selection of suitable conductors in a network planning exercise. I have set up two functions – one of the functions sets up the objective function which is to calculate the total cost based on the type of conductor and the cost associated with the type of conductor. The total cost is thus calculated based on the code below.
function TotCost = minTotCost(RepCondpath,fdrpath1,sheetname)
%fdrpath1: describes the path to the an excel file with the conductors on
%the network while RepCondpath described the path to the costs associated
%with each type of conductor.
[TR,TAmp, C_index]=rep_repository_cr_opt(RepCondpath);
[R,Amp]=getInitialCon_par(fdrpath1,sheetname);
% examine the Resistance of the conductor
% check the TR to find out the value of the
C_weights=C_index;
cost =zeros(length(R),1);
for i =1:length (R)
disp(i);
j= TR == R(i);
cost(i) = C_weights(j);
end
TotCost= sum(cost);
The second thing is to describe the constraints function. In this case, the two constraints are voltage levels (NPI) and conductor loading (CPI). These two are calculated based on the a powerflow function- which calculate the network’s NPI and CPI using the following constraint function.
function[NPI,CPI]=ConstraintFnc(fdrpath1,sheetname)
fname1 = fdrpath1;sheet = sheetname;
fdrcon=get_fdrcon(fdrpath1,sheetname);
[VA,VB,VC,~,IA,IB,IC]= start_f7(1,1,1,1,sheetname,fdrpath1); % This is the powerflow function
ResRange1 = "G6:G12"; AmpRange="AG6:AG12";
R=xlsread(fname1,sheet,ResRange1);
Amp=xlsread(fname1,sheet,AmpRange);
[CPI,NPI]= BNPerf_opt(VA, VB, VC, IA, IB, IC); % This is the function that calculates the CPI and NPI
The objective is to find conductors in TR whose combination has the least total cost. How do I bring these two functions together to run on Matlab.Hi everyone.
I have an optimization problem that seeks to aid the selection of suitable conductors in a network planning exercise. I have set up two functions – one of the functions sets up the objective function which is to calculate the total cost based on the type of conductor and the cost associated with the type of conductor. The total cost is thus calculated based on the code below.
function TotCost = minTotCost(RepCondpath,fdrpath1,sheetname)
%fdrpath1: describes the path to the an excel file with the conductors on
%the network while RepCondpath described the path to the costs associated
%with each type of conductor.
[TR,TAmp, C_index]=rep_repository_cr_opt(RepCondpath);
[R,Amp]=getInitialCon_par(fdrpath1,sheetname);
% examine the Resistance of the conductor
% check the TR to find out the value of the
C_weights=C_index;
cost =zeros(length(R),1);
for i =1:length (R)
disp(i);
j= TR == R(i);
cost(i) = C_weights(j);
end
TotCost= sum(cost);
The second thing is to describe the constraints function. In this case, the two constraints are voltage levels (NPI) and conductor loading (CPI). These two are calculated based on the a powerflow function- which calculate the network’s NPI and CPI using the following constraint function.
function[NPI,CPI]=ConstraintFnc(fdrpath1,sheetname)
fname1 = fdrpath1;sheet = sheetname;
fdrcon=get_fdrcon(fdrpath1,sheetname);
[VA,VB,VC,~,IA,IB,IC]= start_f7(1,1,1,1,sheetname,fdrpath1); % This is the powerflow function
ResRange1 = "G6:G12"; AmpRange="AG6:AG12";
R=xlsread(fname1,sheet,ResRange1);
Amp=xlsread(fname1,sheet,AmpRange);
[CPI,NPI]= BNPerf_opt(VA, VB, VC, IA, IB, IC); % This is the function that calculates the CPI and NPI
The objective is to find conductors in TR whose combination has the least total cost. How do I bring these two functions together to run on Matlab. Hi everyone.
I have an optimization problem that seeks to aid the selection of suitable conductors in a network planning exercise. I have set up two functions – one of the functions sets up the objective function which is to calculate the total cost based on the type of conductor and the cost associated with the type of conductor. The total cost is thus calculated based on the code below.
function TotCost = minTotCost(RepCondpath,fdrpath1,sheetname)
%fdrpath1: describes the path to the an excel file with the conductors on
%the network while RepCondpath described the path to the costs associated
%with each type of conductor.
[TR,TAmp, C_index]=rep_repository_cr_opt(RepCondpath);
[R,Amp]=getInitialCon_par(fdrpath1,sheetname);
% examine the Resistance of the conductor
% check the TR to find out the value of the
C_weights=C_index;
cost =zeros(length(R),1);
for i =1:length (R)
disp(i);
j= TR == R(i);
cost(i) = C_weights(j);
end
TotCost= sum(cost);
The second thing is to describe the constraints function. In this case, the two constraints are voltage levels (NPI) and conductor loading (CPI). These two are calculated based on the a powerflow function- which calculate the network’s NPI and CPI using the following constraint function.
function[NPI,CPI]=ConstraintFnc(fdrpath1,sheetname)
fname1 = fdrpath1;sheet = sheetname;
fdrcon=get_fdrcon(fdrpath1,sheetname);
[VA,VB,VC,~,IA,IB,IC]= start_f7(1,1,1,1,sheetname,fdrpath1); % This is the powerflow function
ResRange1 = "G6:G12"; AmpRange="AG6:AG12";
R=xlsread(fname1,sheet,ResRange1);
Amp=xlsread(fname1,sheet,AmpRange);
[CPI,NPI]= BNPerf_opt(VA, VB, VC, IA, IB, IC); % This is the function that calculates the CPI and NPI
The objective is to find conductors in TR whose combination has the least total cost. How do I bring these two functions together to run on Matlab. ga, optimization, conductor selection MATLAB Answers — New Questions
Tabla de Contenido
Existe forma de agregar Bookmarks a los pdf que los aperturo a traves de microsoft edge, seria en la seccion resaltada en amarillo
Existe forma de agregar Bookmarks a los pdf que los aperturo a traves de microsoft edge, seria en la seccion resaltada en amarillo Read More
Macros in word have died
I am a newbie here; I generally never post anything on message boards. But I am at a complete loss. I don’t know anything about coding, and I absolutely hate being forced into learning VBA for anything but alphabet soup.
A couple of weeks ago, one of my macros that I had been using for about a year just stopped working. There was no explanation. It just stopped working. Then another one died, and another. I am finally down to none of the macros I recorded in Word working. I use these about 20 times a day to reformat other people’s copies, so it’s not like it is convenient to do without them. (remove all hyperlinks, extra returns, tabs, and add an indent). All individual macros using keyboard commands.
Unless someone has an answer, I am going to be forced to copy the original and paste into a new doc with no formatting. Which creates a whole new set of problems — I will have to compare. the two docs to see what the writer had formatted (italics, bullets, bold, etc) and redo their work.
I use Office 365 a Mac with Sonoma OS.
Like I said, I am no program and should not have to learn VBA because the macros were working until recently.
Thank you to anyone who can help!
I am a newbie here; I generally never post anything on message boards. But I am at a complete loss. I don’t know anything about coding, and I absolutely hate being forced into learning VBA for anything but alphabet soup.A couple of weeks ago, one of my macros that I had been using for about a year just stopped working. There was no explanation. It just stopped working. Then another one died, and another. I am finally down to none of the macros I recorded in Word working. I use these about 20 times a day to reformat other people’s copies, so it’s not like it is convenient to do without them. (remove all hyperlinks, extra returns, tabs, and add an indent). All individual macros using keyboard commands. Unless someone has an answer, I am going to be forced to copy the original and paste into a new doc with no formatting. Which creates a whole new set of problems — I will have to compare. the two docs to see what the writer had formatted (italics, bullets, bold, etc) and redo their work.I use Office 365 a Mac with Sonoma OS.Like I said, I am no program and should not have to learn VBA because the macros were working until recently.Thank you to anyone who can help! Read More
How do I feed ODE45 a cell array ?
I am trying to solve an ODE which consists of function handles. In order to formulate the equation of state vector derivative of the System of 1st order ODEs, I collect these function handles in a cell array. It is not possible to store them in a normal array as far as I know. How do I feed the cell Array, which contains all the function handles to the ODE45 solver or do it differently?
Scheme of the problem:
%create cell and state array
state = @(x,y,z) [x;y;z];
Cell_array = cell(3);
%column selector
select_column = @(M, col_index) M(:,col_index);
%Define Matrix Functions, here 2 examples of Matrices
Matrix_1 = @(state) [1,1,state(1); 1,1,sin(state(2));1,1,state(3)];
Matrix_2 = @(state) [state(1),0,0; 0,state(2),0; 0,0, state(2)];
%select the columns
M1_c1 = @(state) select_column(Matrix_1(state),1);
M1_c2 = @(state) select_column(Matrix_1(state),2);
M1_c3 = @(state) select_column(Matrix_1(state),3);
%differential equations
state_dot_1 = @(state) Matrix_2(state) * M1_c1(state);
state_dot_2 = @(state) Matrix_2(state) * M1_c2(state);
state_dot_3 = @(state) Matrix_2(state) * M1_c3(state);
%fill cell array with differential equations
Cell_array{1} = state_dot_1;
Cell_array{2} = state_dot_2;
Cell_array{3} = state_dot_3;
I would now like to feed that cell_array to an ODE solver. This doesn’t work. But using a normal array doesn’t work either for these function handles. Does anyone know a work around ? I’m new to matlab and programming in general.I am trying to solve an ODE which consists of function handles. In order to formulate the equation of state vector derivative of the System of 1st order ODEs, I collect these function handles in a cell array. It is not possible to store them in a normal array as far as I know. How do I feed the cell Array, which contains all the function handles to the ODE45 solver or do it differently?
Scheme of the problem:
%create cell and state array
state = @(x,y,z) [x;y;z];
Cell_array = cell(3);
%column selector
select_column = @(M, col_index) M(:,col_index);
%Define Matrix Functions, here 2 examples of Matrices
Matrix_1 = @(state) [1,1,state(1); 1,1,sin(state(2));1,1,state(3)];
Matrix_2 = @(state) [state(1),0,0; 0,state(2),0; 0,0, state(2)];
%select the columns
M1_c1 = @(state) select_column(Matrix_1(state),1);
M1_c2 = @(state) select_column(Matrix_1(state),2);
M1_c3 = @(state) select_column(Matrix_1(state),3);
%differential equations
state_dot_1 = @(state) Matrix_2(state) * M1_c1(state);
state_dot_2 = @(state) Matrix_2(state) * M1_c2(state);
state_dot_3 = @(state) Matrix_2(state) * M1_c3(state);
%fill cell array with differential equations
Cell_array{1} = state_dot_1;
Cell_array{2} = state_dot_2;
Cell_array{3} = state_dot_3;
I would now like to feed that cell_array to an ODE solver. This doesn’t work. But using a normal array doesn’t work either for these function handles. Does anyone know a work around ? I’m new to matlab and programming in general. I am trying to solve an ODE which consists of function handles. In order to formulate the equation of state vector derivative of the System of 1st order ODEs, I collect these function handles in a cell array. It is not possible to store them in a normal array as far as I know. How do I feed the cell Array, which contains all the function handles to the ODE45 solver or do it differently?
Scheme of the problem:
%create cell and state array
state = @(x,y,z) [x;y;z];
Cell_array = cell(3);
%column selector
select_column = @(M, col_index) M(:,col_index);
%Define Matrix Functions, here 2 examples of Matrices
Matrix_1 = @(state) [1,1,state(1); 1,1,sin(state(2));1,1,state(3)];
Matrix_2 = @(state) [state(1),0,0; 0,state(2),0; 0,0, state(2)];
%select the columns
M1_c1 = @(state) select_column(Matrix_1(state),1);
M1_c2 = @(state) select_column(Matrix_1(state),2);
M1_c3 = @(state) select_column(Matrix_1(state),3);
%differential equations
state_dot_1 = @(state) Matrix_2(state) * M1_c1(state);
state_dot_2 = @(state) Matrix_2(state) * M1_c2(state);
state_dot_3 = @(state) Matrix_2(state) * M1_c3(state);
%fill cell array with differential equations
Cell_array{1} = state_dot_1;
Cell_array{2} = state_dot_2;
Cell_array{3} = state_dot_3;
I would now like to feed that cell_array to an ODE solver. This doesn’t work. But using a normal array doesn’t work either for these function handles. Does anyone know a work around ? I’m new to matlab and programming in general. function handles, ode45, cell array MATLAB Answers — New Questions
How to resolve this error: Unable to perform assignment because the size of the left side is 1000-by-1 and the size of the right side is 1000-by-1000
Howe to resolve this error:
Unable to perform assignment because the size of the left side is 1000-by-1 and the size of the right
side is 1000-by-1000.
Error in servssnr (line 43)
ynoisy(:,ii) = awgn(real(y),snr(ii),’measured’); % Add AWGN
This is my full code:
PRF = 500e3; % Pulse Repetition Frequency (Hz)
sampling_freq = 60e6; % Sampling Frequency (Hz)
carrier_freq = 2.4e9;
rng(‘default’) % Set random number seed for repeatability
M = 4;
EbNo = 0:13;
[ber,ser] = berawgn(EbNo,’pam’,M);
n = 1000; % Number of symbols to process
k = log2(M); % Number of bits per symbol
snr = EbNo+3+10*log10(k); % In dB
ynoisy = zeros(n,length(snr));
z = zeros(n,length(snr));
errVec = zeros(3,length(EbNo));
grid on;
errcalc = comm.ErrorRate;
%x1 = randi([0 M-1],n,1); % Create message signal
% Generate Gold code
code1 = comm.GoldSequence(‘FirstPolynomial’,’x^6+x^5+1′, ‘FirstInitialConditions’,[ 0 0 0 0 0 1], ‘SecondPolynomial’,’x^6+x^5+x^4+x+1′, ‘SecondInitialConditions’,[0 0 0 0 0 1], ‘Index’,1, ‘SamplesPerFrame’,1000);
gold_code = code1();
% Generate Kasami code
kasamiseq = comm.KasamiSequence(‘Polynomial’,[6 5 4 1 0], ‘InitialConditions’,[ 0 0 0 0 0 1],’SamplesPerFrame’,1000);
kasami_code = kasamiseq()
y1 = pammod(gold_code,M); % Modulate
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y1),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(gold_code,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’r’);
hold on;
% Modulate kasami code with barker code
x5 = cos(2*pi*carrier_freq*(0:numel(gold_code)-1)/sampling_freq) .* (gold_code .* kasami_code.’);
y = pammod(x5,M); % Modulate
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(x5,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’b’);
hold on;
y2 = pammod(kasami_code,M);
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y2),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(kasami_code,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’g’);
legend(‘Gold code’,’Gold-Kasami’, ‘Kasami’);
title(‘Comparison of SER ‘);
xlabel(‘E_b/N_0 (dB)’);
ylabel(‘Symbol Error Rate’);
grid on;
hold off;Howe to resolve this error:
Unable to perform assignment because the size of the left side is 1000-by-1 and the size of the right
side is 1000-by-1000.
Error in servssnr (line 43)
ynoisy(:,ii) = awgn(real(y),snr(ii),’measured’); % Add AWGN
This is my full code:
PRF = 500e3; % Pulse Repetition Frequency (Hz)
sampling_freq = 60e6; % Sampling Frequency (Hz)
carrier_freq = 2.4e9;
rng(‘default’) % Set random number seed for repeatability
M = 4;
EbNo = 0:13;
[ber,ser] = berawgn(EbNo,’pam’,M);
n = 1000; % Number of symbols to process
k = log2(M); % Number of bits per symbol
snr = EbNo+3+10*log10(k); % In dB
ynoisy = zeros(n,length(snr));
z = zeros(n,length(snr));
errVec = zeros(3,length(EbNo));
grid on;
errcalc = comm.ErrorRate;
%x1 = randi([0 M-1],n,1); % Create message signal
% Generate Gold code
code1 = comm.GoldSequence(‘FirstPolynomial’,’x^6+x^5+1′, ‘FirstInitialConditions’,[ 0 0 0 0 0 1], ‘SecondPolynomial’,’x^6+x^5+x^4+x+1′, ‘SecondInitialConditions’,[0 0 0 0 0 1], ‘Index’,1, ‘SamplesPerFrame’,1000);
gold_code = code1();
% Generate Kasami code
kasamiseq = comm.KasamiSequence(‘Polynomial’,[6 5 4 1 0], ‘InitialConditions’,[ 0 0 0 0 0 1],’SamplesPerFrame’,1000);
kasami_code = kasamiseq()
y1 = pammod(gold_code,M); % Modulate
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y1),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(gold_code,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’r’);
hold on;
% Modulate kasami code with barker code
x5 = cos(2*pi*carrier_freq*(0:numel(gold_code)-1)/sampling_freq) .* (gold_code .* kasami_code.’);
y = pammod(x5,M); % Modulate
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(x5,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’b’);
hold on;
y2 = pammod(kasami_code,M);
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y2),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(kasami_code,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’g’);
legend(‘Gold code’,’Gold-Kasami’, ‘Kasami’);
title(‘Comparison of SER ‘);
xlabel(‘E_b/N_0 (dB)’);
ylabel(‘Symbol Error Rate’);
grid on;
hold off; Howe to resolve this error:
Unable to perform assignment because the size of the left side is 1000-by-1 and the size of the right
side is 1000-by-1000.
Error in servssnr (line 43)
ynoisy(:,ii) = awgn(real(y),snr(ii),’measured’); % Add AWGN
This is my full code:
PRF = 500e3; % Pulse Repetition Frequency (Hz)
sampling_freq = 60e6; % Sampling Frequency (Hz)
carrier_freq = 2.4e9;
rng(‘default’) % Set random number seed for repeatability
M = 4;
EbNo = 0:13;
[ber,ser] = berawgn(EbNo,’pam’,M);
n = 1000; % Number of symbols to process
k = log2(M); % Number of bits per symbol
snr = EbNo+3+10*log10(k); % In dB
ynoisy = zeros(n,length(snr));
z = zeros(n,length(snr));
errVec = zeros(3,length(EbNo));
grid on;
errcalc = comm.ErrorRate;
%x1 = randi([0 M-1],n,1); % Create message signal
% Generate Gold code
code1 = comm.GoldSequence(‘FirstPolynomial’,’x^6+x^5+1′, ‘FirstInitialConditions’,[ 0 0 0 0 0 1], ‘SecondPolynomial’,’x^6+x^5+x^4+x+1′, ‘SecondInitialConditions’,[0 0 0 0 0 1], ‘Index’,1, ‘SamplesPerFrame’,1000);
gold_code = code1();
% Generate Kasami code
kasamiseq = comm.KasamiSequence(‘Polynomial’,[6 5 4 1 0], ‘InitialConditions’,[ 0 0 0 0 0 1],’SamplesPerFrame’,1000);
kasami_code = kasamiseq()
y1 = pammod(gold_code,M); % Modulate
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y1),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(gold_code,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’r’);
hold on;
% Modulate kasami code with barker code
x5 = cos(2*pi*carrier_freq*(0:numel(gold_code)-1)/sampling_freq) .* (gold_code .* kasami_code.’);
y = pammod(x5,M); % Modulate
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(x5,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’b’);
hold on;
y2 = pammod(kasami_code,M);
for ii = 1:length(snr)
reset(errcalc)
ynoisy(:,ii) = awgn(real(y2),snr(ii),’measured’); % Add AWGN
z(:,ii) = pamdemod(complex(ynoisy(:,ii)),M); % Demodulate
errVec(:,ii) = errcalc(kasami_code,z(:,ii)); % Compute SER from simulation
end
semilogy(EbNo,errVec(1,:),’g’);
legend(‘Gold code’,’Gold-Kasami’, ‘Kasami’);
title(‘Comparison of SER ‘);
xlabel(‘E_b/N_0 (dB)’);
ylabel(‘Symbol Error Rate’);
grid on;
hold off; matlab, digital signal processing, radar, error, dimensions, binary MATLAB Answers — New Questions
How would I properly go about creating this function?
I am doing a project to practice matlab and thought it would be best to be put into a function. This is my function and the rest of my code, I have variables t_values, height_values, and width_values that need to be used outside of the function, but I do not know how to use them from inside the function. These equations are going to be different for the different beams which is why I decided to create a general function. Thanks!
l = 70*12; %length
maxHeight = 12; %maximum height of beam
maxWidth = 10; %maximum width of beam
minHeight = 3; %minimum height of beam
minWidth = 3; %minimum width of beam
maxDef = 10; %maximum beam deformation
w = 3; %distributed load
p = 500; %point force
a = l/3; %distance to point force
E_alum = 9.9*10^6; %aluminum stiffness
E_steel = 28*10^6; %steel stiffness
E_ti = 16*10^6; %titanium stiffness
den_alum = .098; %aluminum density
den_steel = .286; %steel density
den_ti = .16; %titanium density
E = [E_alum, E_steel, E_ti];
density = [den_alum, den_steel, den_ti];
%For combined load
I_min = (w*(l^4)./(E.*30.*maxDef))…
– ((p*(a^2)*((3*l)-a))./(E.*6.*maxDef));
disp(‘I-Beam’);
A_horizI = width_values.*t_values; %Area of flanges
A_vertI = t_values.*(height_values-(2.*t_values)); %Area of web
I_horizI = width_values.*t_values.^3; %Moment of flanges
I_vertI = (t_values.*(height_values-(2.*t_values)).^3)./12; %Moment of web
I_I_beam = I_vertI + 2.*(I_horizI + A_horizI.*((height_values./2)-(t_values./2)).^2); %I for I beam
weightIbeam = @(t, h, w, l, density) (2*w.*t + t.*(h-2.*t))*l*density; %Weight equation for I beam
beamoptimize(I_min, l, density,I_I_beam,weightIbeam);
function beamoptimize( I_min, l, density, I1, weightFunc)
t = 0.1:0.05:1;
height = minHeight:0.05:maxHeight;
width = minWidth:0.05:maxWidth;
V = {t, height, width};
C = cell(1, numel(V));
[C{:}] = ndgrid(V{:});
C = cellfun(@(X) reshape(X, [], 1), C, ‘UniformOutput’, false);
C = horzcat(C{:});
t_values = C(:, 1);
height_values = C(:, 2);
width_values = C(:, 3);
for i = 1:length(I_min)
I = I1;
valid_I = I(I >= I_min(i));
valid_t = t_values(I >= I_min(i));
valid_height = height_values(I >= I_min(i));
valid_width = width_values(I >= I_min(i));
% Calculate weight using the provided weight function
weight = weightFunc(valid_t, valid_height, valid_width, l, density(i));
[min_weight, min_index] = min(weight);
optimal_I = valid_I(min_index);
optimal_t = valid_t(min_index);
optimal_height = valid_height(min_index);
optimal_width = valid_width(min_index);
disp([‘For I_min = ‘, num2str(I_min(i))]);
disp([‘Minimum weight: ‘, num2str(min_weight)]);
disp([‘Optimal valid_I: ‘, num2str(optimal_I)]);
disp([‘Minimum thickness: ‘, num2str(optimal_t)]);
disp([‘Optimal height: ‘, num2str(optimal_height)]);
disp([‘Optimal width: ‘, num2str(optimal_width)]);
disp(‘—————————————‘);
end
endI am doing a project to practice matlab and thought it would be best to be put into a function. This is my function and the rest of my code, I have variables t_values, height_values, and width_values that need to be used outside of the function, but I do not know how to use them from inside the function. These equations are going to be different for the different beams which is why I decided to create a general function. Thanks!
l = 70*12; %length
maxHeight = 12; %maximum height of beam
maxWidth = 10; %maximum width of beam
minHeight = 3; %minimum height of beam
minWidth = 3; %minimum width of beam
maxDef = 10; %maximum beam deformation
w = 3; %distributed load
p = 500; %point force
a = l/3; %distance to point force
E_alum = 9.9*10^6; %aluminum stiffness
E_steel = 28*10^6; %steel stiffness
E_ti = 16*10^6; %titanium stiffness
den_alum = .098; %aluminum density
den_steel = .286; %steel density
den_ti = .16; %titanium density
E = [E_alum, E_steel, E_ti];
density = [den_alum, den_steel, den_ti];
%For combined load
I_min = (w*(l^4)./(E.*30.*maxDef))…
– ((p*(a^2)*((3*l)-a))./(E.*6.*maxDef));
disp(‘I-Beam’);
A_horizI = width_values.*t_values; %Area of flanges
A_vertI = t_values.*(height_values-(2.*t_values)); %Area of web
I_horizI = width_values.*t_values.^3; %Moment of flanges
I_vertI = (t_values.*(height_values-(2.*t_values)).^3)./12; %Moment of web
I_I_beam = I_vertI + 2.*(I_horizI + A_horizI.*((height_values./2)-(t_values./2)).^2); %I for I beam
weightIbeam = @(t, h, w, l, density) (2*w.*t + t.*(h-2.*t))*l*density; %Weight equation for I beam
beamoptimize(I_min, l, density,I_I_beam,weightIbeam);
function beamoptimize( I_min, l, density, I1, weightFunc)
t = 0.1:0.05:1;
height = minHeight:0.05:maxHeight;
width = minWidth:0.05:maxWidth;
V = {t, height, width};
C = cell(1, numel(V));
[C{:}] = ndgrid(V{:});
C = cellfun(@(X) reshape(X, [], 1), C, ‘UniformOutput’, false);
C = horzcat(C{:});
t_values = C(:, 1);
height_values = C(:, 2);
width_values = C(:, 3);
for i = 1:length(I_min)
I = I1;
valid_I = I(I >= I_min(i));
valid_t = t_values(I >= I_min(i));
valid_height = height_values(I >= I_min(i));
valid_width = width_values(I >= I_min(i));
% Calculate weight using the provided weight function
weight = weightFunc(valid_t, valid_height, valid_width, l, density(i));
[min_weight, min_index] = min(weight);
optimal_I = valid_I(min_index);
optimal_t = valid_t(min_index);
optimal_height = valid_height(min_index);
optimal_width = valid_width(min_index);
disp([‘For I_min = ‘, num2str(I_min(i))]);
disp([‘Minimum weight: ‘, num2str(min_weight)]);
disp([‘Optimal valid_I: ‘, num2str(optimal_I)]);
disp([‘Minimum thickness: ‘, num2str(optimal_t)]);
disp([‘Optimal height: ‘, num2str(optimal_height)]);
disp([‘Optimal width: ‘, num2str(optimal_width)]);
disp(‘—————————————‘);
end
end I am doing a project to practice matlab and thought it would be best to be put into a function. This is my function and the rest of my code, I have variables t_values, height_values, and width_values that need to be used outside of the function, but I do not know how to use them from inside the function. These equations are going to be different for the different beams which is why I decided to create a general function. Thanks!
l = 70*12; %length
maxHeight = 12; %maximum height of beam
maxWidth = 10; %maximum width of beam
minHeight = 3; %minimum height of beam
minWidth = 3; %minimum width of beam
maxDef = 10; %maximum beam deformation
w = 3; %distributed load
p = 500; %point force
a = l/3; %distance to point force
E_alum = 9.9*10^6; %aluminum stiffness
E_steel = 28*10^6; %steel stiffness
E_ti = 16*10^6; %titanium stiffness
den_alum = .098; %aluminum density
den_steel = .286; %steel density
den_ti = .16; %titanium density
E = [E_alum, E_steel, E_ti];
density = [den_alum, den_steel, den_ti];
%For combined load
I_min = (w*(l^4)./(E.*30.*maxDef))…
– ((p*(a^2)*((3*l)-a))./(E.*6.*maxDef));
disp(‘I-Beam’);
A_horizI = width_values.*t_values; %Area of flanges
A_vertI = t_values.*(height_values-(2.*t_values)); %Area of web
I_horizI = width_values.*t_values.^3; %Moment of flanges
I_vertI = (t_values.*(height_values-(2.*t_values)).^3)./12; %Moment of web
I_I_beam = I_vertI + 2.*(I_horizI + A_horizI.*((height_values./2)-(t_values./2)).^2); %I for I beam
weightIbeam = @(t, h, w, l, density) (2*w.*t + t.*(h-2.*t))*l*density; %Weight equation for I beam
beamoptimize(I_min, l, density,I_I_beam,weightIbeam);
function beamoptimize( I_min, l, density, I1, weightFunc)
t = 0.1:0.05:1;
height = minHeight:0.05:maxHeight;
width = minWidth:0.05:maxWidth;
V = {t, height, width};
C = cell(1, numel(V));
[C{:}] = ndgrid(V{:});
C = cellfun(@(X) reshape(X, [], 1), C, ‘UniformOutput’, false);
C = horzcat(C{:});
t_values = C(:, 1);
height_values = C(:, 2);
width_values = C(:, 3);
for i = 1:length(I_min)
I = I1;
valid_I = I(I >= I_min(i));
valid_t = t_values(I >= I_min(i));
valid_height = height_values(I >= I_min(i));
valid_width = width_values(I >= I_min(i));
% Calculate weight using the provided weight function
weight = weightFunc(valid_t, valid_height, valid_width, l, density(i));
[min_weight, min_index] = min(weight);
optimal_I = valid_I(min_index);
optimal_t = valid_t(min_index);
optimal_height = valid_height(min_index);
optimal_width = valid_width(min_index);
disp([‘For I_min = ‘, num2str(I_min(i))]);
disp([‘Minimum weight: ‘, num2str(min_weight)]);
disp([‘Optimal valid_I: ‘, num2str(optimal_I)]);
disp([‘Minimum thickness: ‘, num2str(optimal_t)]);
disp([‘Optimal height: ‘, num2str(optimal_height)]);
disp([‘Optimal width: ‘, num2str(optimal_width)]);
disp(‘—————————————‘);
end
end help, functions, matlab MATLAB Answers — New Questions
PDEPE solver failure (spatial discretization) ; partial differential/derivative temperature modelling
Attempting to model temperature profile of an adsorption column based on concentration profile since this determines the heat of adsorption.
This is the function:
function[c,f,s] = pdefunEB(x,t,u,dudx)
global qmax_phenol K_L_phenol kf De u_s Rep Dp epsilon rho_liq cp_AC cp_feed H_ads h alpha
C = u(1) ;
q = u(2) ;
Tf = u(3) ;
dCdx = dudx(1) ;
dqdx = dudx(2) ;
dTdx = dudx(3) ;
Ts = 298.15 ; % adsorbent temp Kelvin
qstar = ((qmax_phenol)*(K_L_phenol)*C)/(1+(K_L_phenol)*C) ;
dqdt = kf*(qstar-q) ;
c = ones(3,1) ;
f = [De*dCdx;
0;
0];
s = [-u_s*dCdx-(1-epsilon)/epsilon*rho_liq*dqdt;
dqdt;
-u_s*dTdx+(((h*alpha*(Tf-Ts)-(H_ads/cp_AC))+(H_ads/cp_feed))*(dqdt*((1-epsilon)/epsilon)))] ;
end
%% initial condition
function u0 = icfunEB(x)
u0 = [0;
0;
298.15] ;
end
%% boundary condition
function [p1,q1,pr,qr] = bcfunEB(x1,u1,xr,ur,t)
global C_phenol
C0 = C_phenol ;
p1 = [u1(1)-C0;0;-298.15] ;
q1 = [0;1;0] ;
pr = [0;0;0] ;
qr = [1;1;1] ;
end
this is where the error appears (Error using pdepe Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative)
mEB = 0 ;
sol1 = pdepe(mEB,@pdefunEB,@icfunEB,@bcfunEB,x,t) ;
CEB = sol1(:,:,1) ;
qEB = sol1(:,:,2) ;
TEB = sol1(:,:,3) ;
figure(2)
T0 = 298.15 ;
Cp1 = C1(:,end)./C01 ;
plot(t,TEB,’b-‘,’LineWidth’,2)
grid on
title(‘Column Temperature’)
xlabel(‘time in minutes’)
ylabel(‘temp in kelvin’)
Heres a picture of my mathematical working before input into matlab:Attempting to model temperature profile of an adsorption column based on concentration profile since this determines the heat of adsorption.
This is the function:
function[c,f,s] = pdefunEB(x,t,u,dudx)
global qmax_phenol K_L_phenol kf De u_s Rep Dp epsilon rho_liq cp_AC cp_feed H_ads h alpha
C = u(1) ;
q = u(2) ;
Tf = u(3) ;
dCdx = dudx(1) ;
dqdx = dudx(2) ;
dTdx = dudx(3) ;
Ts = 298.15 ; % adsorbent temp Kelvin
qstar = ((qmax_phenol)*(K_L_phenol)*C)/(1+(K_L_phenol)*C) ;
dqdt = kf*(qstar-q) ;
c = ones(3,1) ;
f = [De*dCdx;
0;
0];
s = [-u_s*dCdx-(1-epsilon)/epsilon*rho_liq*dqdt;
dqdt;
-u_s*dTdx+(((h*alpha*(Tf-Ts)-(H_ads/cp_AC))+(H_ads/cp_feed))*(dqdt*((1-epsilon)/epsilon)))] ;
end
%% initial condition
function u0 = icfunEB(x)
u0 = [0;
0;
298.15] ;
end
%% boundary condition
function [p1,q1,pr,qr] = bcfunEB(x1,u1,xr,ur,t)
global C_phenol
C0 = C_phenol ;
p1 = [u1(1)-C0;0;-298.15] ;
q1 = [0;1;0] ;
pr = [0;0;0] ;
qr = [1;1;1] ;
end
this is where the error appears (Error using pdepe Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative)
mEB = 0 ;
sol1 = pdepe(mEB,@pdefunEB,@icfunEB,@bcfunEB,x,t) ;
CEB = sol1(:,:,1) ;
qEB = sol1(:,:,2) ;
TEB = sol1(:,:,3) ;
figure(2)
T0 = 298.15 ;
Cp1 = C1(:,end)./C01 ;
plot(t,TEB,’b-‘,’LineWidth’,2)
grid on
title(‘Column Temperature’)
xlabel(‘time in minutes’)
ylabel(‘temp in kelvin’)
Heres a picture of my mathematical working before input into matlab: Attempting to model temperature profile of an adsorption column based on concentration profile since this determines the heat of adsorption.
This is the function:
function[c,f,s] = pdefunEB(x,t,u,dudx)
global qmax_phenol K_L_phenol kf De u_s Rep Dp epsilon rho_liq cp_AC cp_feed H_ads h alpha
C = u(1) ;
q = u(2) ;
Tf = u(3) ;
dCdx = dudx(1) ;
dqdx = dudx(2) ;
dTdx = dudx(3) ;
Ts = 298.15 ; % adsorbent temp Kelvin
qstar = ((qmax_phenol)*(K_L_phenol)*C)/(1+(K_L_phenol)*C) ;
dqdt = kf*(qstar-q) ;
c = ones(3,1) ;
f = [De*dCdx;
0;
0];
s = [-u_s*dCdx-(1-epsilon)/epsilon*rho_liq*dqdt;
dqdt;
-u_s*dTdx+(((h*alpha*(Tf-Ts)-(H_ads/cp_AC))+(H_ads/cp_feed))*(dqdt*((1-epsilon)/epsilon)))] ;
end
%% initial condition
function u0 = icfunEB(x)
u0 = [0;
0;
298.15] ;
end
%% boundary condition
function [p1,q1,pr,qr] = bcfunEB(x1,u1,xr,ur,t)
global C_phenol
C0 = C_phenol ;
p1 = [u1(1)-C0;0;-298.15] ;
q1 = [0;1;0] ;
pr = [0;0;0] ;
qr = [1;1;1] ;
end
this is where the error appears (Error using pdepe Spatial discretization has failed. Discretization supports only parabolic and elliptic equations, with flux term involving spatial derivative)
mEB = 0 ;
sol1 = pdepe(mEB,@pdefunEB,@icfunEB,@bcfunEB,x,t) ;
CEB = sol1(:,:,1) ;
qEB = sol1(:,:,2) ;
TEB = sol1(:,:,3) ;
figure(2)
T0 = 298.15 ;
Cp1 = C1(:,end)./C01 ;
plot(t,TEB,’b-‘,’LineWidth’,2)
grid on
title(‘Column Temperature’)
xlabel(‘time in minutes’)
ylabel(‘temp in kelvin’)
Heres a picture of my mathematical working before input into matlab: pdepe, partials, partialdifferentials, partialderivatives, adsorption, chemical engineering, spatial discretisation MATLAB Answers — New Questions
Why is the conditional statement not working as per the condition given?
horizon=0.3;
spacing=0.1;
length=1;
numberOfParticlesAlongX=floor(length/spacing);
numberOfParticlesInDomain=numberOfParticlesAlongX; %Number of particles in X-direction attributed to domain
xComponent(1:numberOfParticlesAlongX)=((1:numberOfParticlesAlongX)-1)*spacing; %Co-ordinate of each particle stored in xComponent
CORD=xComponent;
for i=1:numberOfParticlesInDomain
p=1;
for j=1:numberOfParticlesInDomain
if i~=j %Condition for checking undesired presence of a particle in its own neighbourhood
d=abs(CORD(i)-CORD(j)); %Distance between the two particles is stored in’d’ for comparison with the horizon value
if d<=horizon
neighbourhoodArray(i,p)=j;
p=p+1; %’p’ is incremented at every step to store only the particles within the horizon distance of a particular particle.
end
end
end
end
disp(neighbourhoodArray);
This code is part of a project on material failure modelling. I need to store all the particles (labelled as ‘j’ in the for loop) within a certain distance (lablled as ‘horizon’) from a particular particle (labelled as ‘i’ in the for loop). With the given data of horizon=0.3, spacing (between particles)=0.1, and length=1, number of particles in the domain will come out to be 10. The x-component of 1st particle is ‘0’ and that of the last one is ‘0.9’, as in the ‘xComponent’ array.
Now, with the given data, for the first particle (with CORD(1)=0), the neighbourhood particles should be those at CORD(2)=0.1 (Particle-2), CORD(3)=0.2 (Particle-3), CORD(3)=0.3 (Particle-4). But, in the neighbourhoodArray array, for the 1st particle, only Particle-2 and Particle-3 are being shown to be in the neighbourhood of Particle-1, which is incorrect.
I ran the code statement-by-statement using ‘Step’ and found that the compiler is not executing the statement under "if d<=horizon" when ‘d’ and ‘horizon’ have the same value (=0.3). I really don’t understand what the problem is with the conditional statement, as I think the logic that I have used is correct.horizon=0.3;
spacing=0.1;
length=1;
numberOfParticlesAlongX=floor(length/spacing);
numberOfParticlesInDomain=numberOfParticlesAlongX; %Number of particles in X-direction attributed to domain
xComponent(1:numberOfParticlesAlongX)=((1:numberOfParticlesAlongX)-1)*spacing; %Co-ordinate of each particle stored in xComponent
CORD=xComponent;
for i=1:numberOfParticlesInDomain
p=1;
for j=1:numberOfParticlesInDomain
if i~=j %Condition for checking undesired presence of a particle in its own neighbourhood
d=abs(CORD(i)-CORD(j)); %Distance between the two particles is stored in’d’ for comparison with the horizon value
if d<=horizon
neighbourhoodArray(i,p)=j;
p=p+1; %’p’ is incremented at every step to store only the particles within the horizon distance of a particular particle.
end
end
end
end
disp(neighbourhoodArray);
This code is part of a project on material failure modelling. I need to store all the particles (labelled as ‘j’ in the for loop) within a certain distance (lablled as ‘horizon’) from a particular particle (labelled as ‘i’ in the for loop). With the given data of horizon=0.3, spacing (between particles)=0.1, and length=1, number of particles in the domain will come out to be 10. The x-component of 1st particle is ‘0’ and that of the last one is ‘0.9’, as in the ‘xComponent’ array.
Now, with the given data, for the first particle (with CORD(1)=0), the neighbourhood particles should be those at CORD(2)=0.1 (Particle-2), CORD(3)=0.2 (Particle-3), CORD(3)=0.3 (Particle-4). But, in the neighbourhoodArray array, for the 1st particle, only Particle-2 and Particle-3 are being shown to be in the neighbourhood of Particle-1, which is incorrect.
I ran the code statement-by-statement using ‘Step’ and found that the compiler is not executing the statement under "if d<=horizon" when ‘d’ and ‘horizon’ have the same value (=0.3). I really don’t understand what the problem is with the conditional statement, as I think the logic that I have used is correct. horizon=0.3;
spacing=0.1;
length=1;
numberOfParticlesAlongX=floor(length/spacing);
numberOfParticlesInDomain=numberOfParticlesAlongX; %Number of particles in X-direction attributed to domain
xComponent(1:numberOfParticlesAlongX)=((1:numberOfParticlesAlongX)-1)*spacing; %Co-ordinate of each particle stored in xComponent
CORD=xComponent;
for i=1:numberOfParticlesInDomain
p=1;
for j=1:numberOfParticlesInDomain
if i~=j %Condition for checking undesired presence of a particle in its own neighbourhood
d=abs(CORD(i)-CORD(j)); %Distance between the two particles is stored in’d’ for comparison with the horizon value
if d<=horizon
neighbourhoodArray(i,p)=j;
p=p+1; %’p’ is incremented at every step to store only the particles within the horizon distance of a particular particle.
end
end
end
end
disp(neighbourhoodArray);
This code is part of a project on material failure modelling. I need to store all the particles (labelled as ‘j’ in the for loop) within a certain distance (lablled as ‘horizon’) from a particular particle (labelled as ‘i’ in the for loop). With the given data of horizon=0.3, spacing (between particles)=0.1, and length=1, number of particles in the domain will come out to be 10. The x-component of 1st particle is ‘0’ and that of the last one is ‘0.9’, as in the ‘xComponent’ array.
Now, with the given data, for the first particle (with CORD(1)=0), the neighbourhood particles should be those at CORD(2)=0.1 (Particle-2), CORD(3)=0.2 (Particle-3), CORD(3)=0.3 (Particle-4). But, in the neighbourhoodArray array, for the 1st particle, only Particle-2 and Particle-3 are being shown to be in the neighbourhood of Particle-1, which is incorrect.
I ran the code statement-by-statement using ‘Step’ and found that the compiler is not executing the statement under "if d<=horizon" when ‘d’ and ‘horizon’ have the same value (=0.3). I really don’t understand what the problem is with the conditional statement, as I think the logic that I have used is correct. matlab, conditional statement, array MATLAB Answers — New Questions
How to put conditions to find peaks in NDVI time series?
I am using following matlab code
findpeaks(data,days’MinPeakProminence’,60)
xlabel(‘days’)
ylabel(‘NDVI’)
title(‘Find Prominent Peaks’) here the data is NDVI time series attached here.I am using following matlab code
findpeaks(data,days’MinPeakProminence’,60)
xlabel(‘days’)
ylabel(‘NDVI’)
title(‘Find Prominent Peaks’) here the data is NDVI time series attached here. I am using following matlab code
findpeaks(data,days’MinPeakProminence’,60)
xlabel(‘days’)
ylabel(‘NDVI’)
title(‘Find Prominent Peaks’) here the data is NDVI time series attached here. how to put conditions for finding peaks? MATLAB Answers — New Questions
Print Button options in Word
New to this community and a newbie question.
Is it possible to add a print button to a word document that opens the print document dialog box?
I have figured out how to add an ActiveX Command button with [ActiveDocument.PrintOut Range:=wdPrintCurrentPage]. Unfortunately that prints directly to the default printer. I can see this causing some issues in a n office with multiple printers..
Additional context: I am working with a French and English document (more of a form). At some point I would like to have two print buttons, one for the french pages and the other for the english pages.
Maybe there is a better way than a print button? Maybe there is a way to click a button and have an alternate language come up or groups of fields turn on/off.
New to this community and a newbie question.Is it possible to add a print button to a word document that opens the print document dialog box?I have figured out how to add an ActiveX Command button with [ActiveDocument.PrintOut Range:=wdPrintCurrentPage]. Unfortunately that prints directly to the default printer. I can see this causing some issues in a n office with multiple printers.. Additional context: I am working with a French and English document (more of a form). At some point I would like to have two print buttons, one for the french pages and the other for the english pages. Maybe there is a better way than a print button? Maybe there is a way to click a button and have an alternate language come up or groups of fields turn on/off. Read More