Category: Matlab
Category Archives: Matlab
Video Labeler change time between frames
I am using the videolabeler to annotate timelapse videos taken with a microscope, is there any where I can change the start and end time, as well as the time between frames?
It seems like this is preset and I could not find anywhere to change it.
Thanks!I am using the videolabeler to annotate timelapse videos taken with a microscope, is there any where I can change the start and end time, as well as the time between frames?
It seems like this is preset and I could not find anywhere to change it.
Thanks! I am using the videolabeler to annotate timelapse videos taken with a microscope, is there any where I can change the start and end time, as well as the time between frames?
It seems like this is preset and I could not find anywhere to change it.
Thanks! videolabler, annotation, videos MATLAB Answers — New Questions
Does the curvefit toolbox return the equation for the best fit line (or curve)?
For example, let’s say that a 5th order polynomial fits the data nicely. Does the curvefit results include the equation, or at least the coefficients, of the 5th order polynomial fit?
Perhaps a silly question, but you might be surprized at how many so-called curve fitting programs are out there that only care about displaying the fit.
Thank you for considering my question.
ToddFor example, let’s say that a 5th order polynomial fits the data nicely. Does the curvefit results include the equation, or at least the coefficients, of the 5th order polynomial fit?
Perhaps a silly question, but you might be surprized at how many so-called curve fitting programs are out there that only care about displaying the fit.
Thank you for considering my question.
Todd For example, let’s say that a 5th order polynomial fits the data nicely. Does the curvefit results include the equation, or at least the coefficients, of the 5th order polynomial fit?
Perhaps a silly question, but you might be surprized at how many so-called curve fitting programs are out there that only care about displaying the fit.
Thank you for considering my question.
Todd curve fitting MATLAB Answers — New Questions
failing to run Reinforcement learning job on the cluster
I have a custom reinforcement learning environment in which I train an agent using the SAC algorithm. The training runs smoothly on my desktop with four cores, but attempting to speed up the process on the university cluster has been unsuccessful. Below is some information about the job. Can this issue be resolved?
>> (jobRL5)
jobRL5 =
Job
Properties:
ID: 103
Type: pool
Username: amomani1
State: failed
SubmitDateTime: 13-May-2024 18:25:52
StartDateTime: 13-May-2024 18:27:12
RunningDuration: 0 days 13h 39m 28s
NumWorkersRange: [11 11]
NumThreads: 2
AutoAttachFiles: true
Auto Attached Files: List files
AttachedFiles: R:amomani1matlabcodes_SI_2023atalbot_inversion.m
R:amomani1matlabcodes_SI_2023atalbot_inversion2.m
R:amomani1matlabcodes_SI_2023atalbotcode.m
AutoAddClientPath: true
AdditionalPaths: \lightning.bu.binghamton.edumatlabnonshared23aIntegrationScriptsspiedie
\lightning.bu.binghamton.edumatlabnonshared23a
C:Usersamomani1DocumentsMATLAB
C:Usersamomani1AppDataLocalTemp8Editor_retgg
FileStore: [1×1 parallel.FileStore]
ValueStore: [1×1 parallel.ValueStore]
EnvironmentVariables: {}
Associated Tasks:
Number Pending: 0
Number Running: 0
Number Finished: 11
Task ID of Errors: []
Task ID of Warnings: []
Task Scheduler IDs: 4857192
>> c.getDebugLog(jobRL5)
LOG FILE OUTPUT:
Node file: compute[078,162]
Starting SMPD on compute078 compute162 …
srun –ntasks-per-node=1 –ntasks=2 /cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -debug 0 &
Checking that SMPD processes are running (Attempt 1 of 60)
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute078 > /dev/null 2>&1
No SMPD process running on compute078
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute162 > /dev/null 2>&1
No SMPD process running on compute162
Checking that SMPD processes are running (Attempt 2 of 60)
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute078 > /dev/null 2>&1
SMPD process found running on compute078
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute162 > /dev/null 2>&1
SMPD process found running on compute162
All SMPDs launched
Machine args: -hosts 2 compute078 6 compute162 6
"/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_mpiexec" -smpd -phrase MATLAB -port 27192 -l -hosts 2 compute078 6 compute162 6 -genvlist PARALLEL_SERVER_DECODE_FUNCTION,PARALLEL_SERVER_STORAGE_LOCATION,PARALLEL_SERVER_STORAGE_CONSTRUCTOR,PARALLEL_SERVER_JOB_LOCATION,PARALLEL_SERVER_DEBUG,PARALLEL_SERVER_LICENSE_NUMBER,MLM_WEB_LICENSE,MLM_WEB_USER_CRED,MLM_WEB_ID,TZ,MDCE_DECODE_FUNCTION,MDCE_STORAGE_LOCATION,MDCE_STORAGE_CONSTRUCTOR,MDCE_JOB_LOCATION,MDCE_DEBUG,MDCE_LICENSE_NUMBER "/cm/shared/apps/Mathworks-MPS/2023a/bin/worker" -parallel
job aborted:
rank: node: exit code[: error message]
0: compute078: -2
1: compute078: -2
2: compute078: -2
3: compute078: -2
4: compute078: -2
5: compute078: -2
6: compute162: -2
7: compute162: -2
8: compute162: -2
9: compute162: -2
10: compute162: -2
11: compute162: 1: process 11 exited without calling finalize
Stopping SMPD …
srun –ntasks-per-node=1 –ntasks=2 /cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -shutdown -phrase MATLAB -port 27192
Exiting with code: 123I have a custom reinforcement learning environment in which I train an agent using the SAC algorithm. The training runs smoothly on my desktop with four cores, but attempting to speed up the process on the university cluster has been unsuccessful. Below is some information about the job. Can this issue be resolved?
>> (jobRL5)
jobRL5 =
Job
Properties:
ID: 103
Type: pool
Username: amomani1
State: failed
SubmitDateTime: 13-May-2024 18:25:52
StartDateTime: 13-May-2024 18:27:12
RunningDuration: 0 days 13h 39m 28s
NumWorkersRange: [11 11]
NumThreads: 2
AutoAttachFiles: true
Auto Attached Files: List files
AttachedFiles: R:amomani1matlabcodes_SI_2023atalbot_inversion.m
R:amomani1matlabcodes_SI_2023atalbot_inversion2.m
R:amomani1matlabcodes_SI_2023atalbotcode.m
AutoAddClientPath: true
AdditionalPaths: \lightning.bu.binghamton.edumatlabnonshared23aIntegrationScriptsspiedie
\lightning.bu.binghamton.edumatlabnonshared23a
C:Usersamomani1DocumentsMATLAB
C:Usersamomani1AppDataLocalTemp8Editor_retgg
FileStore: [1×1 parallel.FileStore]
ValueStore: [1×1 parallel.ValueStore]
EnvironmentVariables: {}
Associated Tasks:
Number Pending: 0
Number Running: 0
Number Finished: 11
Task ID of Errors: []
Task ID of Warnings: []
Task Scheduler IDs: 4857192
>> c.getDebugLog(jobRL5)
LOG FILE OUTPUT:
Node file: compute[078,162]
Starting SMPD on compute078 compute162 …
srun –ntasks-per-node=1 –ntasks=2 /cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -debug 0 &
Checking that SMPD processes are running (Attempt 1 of 60)
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute078 > /dev/null 2>&1
No SMPD process running on compute078
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute162 > /dev/null 2>&1
No SMPD process running on compute162
Checking that SMPD processes are running (Attempt 2 of 60)
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute078 > /dev/null 2>&1
SMPD process found running on compute078
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute162 > /dev/null 2>&1
SMPD process found running on compute162
All SMPDs launched
Machine args: -hosts 2 compute078 6 compute162 6
"/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_mpiexec" -smpd -phrase MATLAB -port 27192 -l -hosts 2 compute078 6 compute162 6 -genvlist PARALLEL_SERVER_DECODE_FUNCTION,PARALLEL_SERVER_STORAGE_LOCATION,PARALLEL_SERVER_STORAGE_CONSTRUCTOR,PARALLEL_SERVER_JOB_LOCATION,PARALLEL_SERVER_DEBUG,PARALLEL_SERVER_LICENSE_NUMBER,MLM_WEB_LICENSE,MLM_WEB_USER_CRED,MLM_WEB_ID,TZ,MDCE_DECODE_FUNCTION,MDCE_STORAGE_LOCATION,MDCE_STORAGE_CONSTRUCTOR,MDCE_JOB_LOCATION,MDCE_DEBUG,MDCE_LICENSE_NUMBER "/cm/shared/apps/Mathworks-MPS/2023a/bin/worker" -parallel
job aborted:
rank: node: exit code[: error message]
0: compute078: -2
1: compute078: -2
2: compute078: -2
3: compute078: -2
4: compute078: -2
5: compute078: -2
6: compute162: -2
7: compute162: -2
8: compute162: -2
9: compute162: -2
10: compute162: -2
11: compute162: 1: process 11 exited without calling finalize
Stopping SMPD …
srun –ntasks-per-node=1 –ntasks=2 /cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -shutdown -phrase MATLAB -port 27192
Exiting with code: 123 I have a custom reinforcement learning environment in which I train an agent using the SAC algorithm. The training runs smoothly on my desktop with four cores, but attempting to speed up the process on the university cluster has been unsuccessful. Below is some information about the job. Can this issue be resolved?
>> (jobRL5)
jobRL5 =
Job
Properties:
ID: 103
Type: pool
Username: amomani1
State: failed
SubmitDateTime: 13-May-2024 18:25:52
StartDateTime: 13-May-2024 18:27:12
RunningDuration: 0 days 13h 39m 28s
NumWorkersRange: [11 11]
NumThreads: 2
AutoAttachFiles: true
Auto Attached Files: List files
AttachedFiles: R:amomani1matlabcodes_SI_2023atalbot_inversion.m
R:amomani1matlabcodes_SI_2023atalbot_inversion2.m
R:amomani1matlabcodes_SI_2023atalbotcode.m
AutoAddClientPath: true
AdditionalPaths: \lightning.bu.binghamton.edumatlabnonshared23aIntegrationScriptsspiedie
\lightning.bu.binghamton.edumatlabnonshared23a
C:Usersamomani1DocumentsMATLAB
C:Usersamomani1AppDataLocalTemp8Editor_retgg
FileStore: [1×1 parallel.FileStore]
ValueStore: [1×1 parallel.ValueStore]
EnvironmentVariables: {}
Associated Tasks:
Number Pending: 0
Number Running: 0
Number Finished: 11
Task ID of Errors: []
Task ID of Warnings: []
Task Scheduler IDs: 4857192
>> c.getDebugLog(jobRL5)
LOG FILE OUTPUT:
Node file: compute[078,162]
Starting SMPD on compute078 compute162 …
srun –ntasks-per-node=1 –ntasks=2 /cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -debug 0 &
Checking that SMPD processes are running (Attempt 1 of 60)
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute078 > /dev/null 2>&1
No SMPD process running on compute078
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute162 > /dev/null 2>&1
No SMPD process running on compute162
Checking that SMPD processes are running (Attempt 2 of 60)
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute078 > /dev/null 2>&1
SMPD process found running on compute078
/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -phrase MATLAB -port 27192 -status compute162 > /dev/null 2>&1
SMPD process found running on compute162
All SMPDs launched
Machine args: -hosts 2 compute078 6 compute162 6
"/cm/shared/apps/Mathworks-MPS/2023a/bin/mw_mpiexec" -smpd -phrase MATLAB -port 27192 -l -hosts 2 compute078 6 compute162 6 -genvlist PARALLEL_SERVER_DECODE_FUNCTION,PARALLEL_SERVER_STORAGE_LOCATION,PARALLEL_SERVER_STORAGE_CONSTRUCTOR,PARALLEL_SERVER_JOB_LOCATION,PARALLEL_SERVER_DEBUG,PARALLEL_SERVER_LICENSE_NUMBER,MLM_WEB_LICENSE,MLM_WEB_USER_CRED,MLM_WEB_ID,TZ,MDCE_DECODE_FUNCTION,MDCE_STORAGE_LOCATION,MDCE_STORAGE_CONSTRUCTOR,MDCE_JOB_LOCATION,MDCE_DEBUG,MDCE_LICENSE_NUMBER "/cm/shared/apps/Mathworks-MPS/2023a/bin/worker" -parallel
job aborted:
rank: node: exit code[: error message]
0: compute078: -2
1: compute078: -2
2: compute078: -2
3: compute078: -2
4: compute078: -2
5: compute078: -2
6: compute162: -2
7: compute162: -2
8: compute162: -2
9: compute162: -2
10: compute162: -2
11: compute162: 1: process 11 exited without calling finalize
Stopping SMPD …
srun –ntasks-per-node=1 –ntasks=2 /cm/shared/apps/Mathworks-MPS/2023a/bin/mw_smpd -shutdown -phrase MATLAB -port 27192
Exiting with code: 123 reinforcement learing, cluster MATLAB Answers — New Questions
How do I construct a mesh in PDE Solver from only the boundary points?
Basically, the title. I have a non-uniform or clustered mesh on which I would like to solve a particular PDE but I can’t figure out how. I know the boundary points and nothing else. Any help?Basically, the title. I have a non-uniform or clustered mesh on which I would like to solve a particular PDE but I can’t figure out how. I know the boundary points and nothing else. Any help? Basically, the title. I have a non-uniform or clustered mesh on which I would like to solve a particular PDE but I can’t figure out how. I know the boundary points and nothing else. Any help? mesh MATLAB Answers — New Questions
How to install Matlab without Oracle java and use Open JDK instead?
How to install Matlab without Oracle java and use Open JDK instead. We think that we need update all our installation to use Open java because Oracle is starting to end free use of java. We use SCCM to install software silent.How to install Matlab without Oracle java and use Open JDK instead. We think that we need update all our installation to use Open java because Oracle is starting to end free use of java. We use SCCM to install software silent. How to install Matlab without Oracle java and use Open JDK instead. We think that we need update all our installation to use Open java because Oracle is starting to end free use of java. We use SCCM to install software silent. open jdk, install matlab MATLAB Answers — New Questions
How set up a parameter in the PDE Modeler App as a function?
Good morning,
i’m studying the freezing process of mozzarella cheese: for T>0°C there is a heat exchange by convection for water content, but for T <0 °C the heat exchange is by conduction due to the presence of ice.
How set up these coefficient as a function? For example refering the value from Matlab’s script? With a "IF Cycle? With a Overlay of convection and conduction effect?
I’ven’t idea :(Good morning,
i’m studying the freezing process of mozzarella cheese: for T>0°C there is a heat exchange by convection for water content, but for T <0 °C the heat exchange is by conduction due to the presence of ice.
How set up these coefficient as a function? For example refering the value from Matlab’s script? With a "IF Cycle? With a Overlay of convection and conduction effect?
I’ven’t idea 🙁 Good morning,
i’m studying the freezing process of mozzarella cheese: for T>0°C there is a heat exchange by convection for water content, but for T <0 °C the heat exchange is by conduction due to the presence of ice.
How set up these coefficient as a function? For example refering the value from Matlab’s script? With a "IF Cycle? With a Overlay of convection and conduction effect?
I’ven’t idea 🙁 pde modeler MATLAB Answers — New Questions
web cam üzerinden nesne boyutu tespit etme
vidaların m8 mi m10 mu tespit etmek ıstiyorum hangı komutları kullanmalıyımvidaların m8 mi m10 mu tespit etmek ıstiyorum hangı komutları kullanmalıyım vidaların m8 mi m10 mu tespit etmek ıstiyorum hangı komutları kullanmalıyım nesne boyutu MATLAB Answers — New Questions
Detect peaks before drop in signal
Hi everyone,
I have this signal where i need to detect only the peak right before the signal drops but I can’t figure out a way to do it. Can anyone give me a hand?
Thank you so much!Hi everyone,
I have this signal where i need to detect only the peak right before the signal drops but I can’t figure out a way to do it. Can anyone give me a hand?
Thank you so much! Hi everyone,
I have this signal where i need to detect only the peak right before the signal drops but I can’t figure out a way to do it. Can anyone give me a hand?
Thank you so much! findpeaks MATLAB Answers — New Questions
don’t understand output of fitlme, intercept substituted for first line.
Hi – I fit some linear mixed effect models using , but the output always substitutes ‘intercept’ for the first line of the fixed effect coefficiants. Why is this?
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower
{‘(Intercept)’ } -1.984e-05 6.4305e-06 -3.0853 37 0.0038374 -3.2869e-05
{‘voc_registers_ADS’ } -9.3714e-06 6.9456e-06 -1.3493 37 0.18545 -2.3444e-05
{‘voc_registers_nonSpeech’} 5.4826e-06 6.4513e-06 0.84985 37 0.40088Hi – I fit some linear mixed effect models using , but the output always substitutes ‘intercept’ for the first line of the fixed effect coefficiants. Why is this?
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower
{‘(Intercept)’ } -1.984e-05 6.4305e-06 -3.0853 37 0.0038374 -3.2869e-05
{‘voc_registers_ADS’ } -9.3714e-06 6.9456e-06 -1.3493 37 0.18545 -2.3444e-05
{‘voc_registers_nonSpeech’} 5.4826e-06 6.4513e-06 0.84985 37 0.40088 Hi – I fit some linear mixed effect models using , but the output always substitutes ‘intercept’ for the first line of the fixed effect coefficiants. Why is this?
Fixed effects coefficients (95% CIs):
Name Estimate SE tStat DF pValue Lower
{‘(Intercept)’ } -1.984e-05 6.4305e-06 -3.0853 37 0.0038374 -3.2869e-05
{‘voc_registers_ADS’ } -9.3714e-06 6.9456e-06 -1.3493 37 0.18545 -2.3444e-05
{‘voc_registers_nonSpeech’} 5.4826e-06 6.4513e-06 0.84985 37 0.40088 lme, linear mixed effect, model MATLAB Answers — New Questions
Data and time dimensions are incompatible when running HIL
I have the same question as Data and time dimensions are incompatible error message – MATLAB Answers – MATLAB Central (mathworks.cn). The difference is that when running HIL, the scope cannot display data, while the data inspector will report the error in a few minutes.This bug seriously affects its usage.Hope it can be resolved.I have the same question as Data and time dimensions are incompatible error message – MATLAB Answers – MATLAB Central (mathworks.cn). The difference is that when running HIL, the scope cannot display data, while the data inspector will report the error in a few minutes.This bug seriously affects its usage.Hope it can be resolved. I have the same question as Data and time dimensions are incompatible error message – MATLAB Answers – MATLAB Central (mathworks.cn). The difference is that when running HIL, the scope cannot display data, while the data inspector will report the error in a few minutes.This bug seriously affects its usage.Hope it can be resolved. speedgoat, simulink, datainspector MATLAB Answers — New Questions
Code runs well on Windows but gets errors on Apple Silicon Mac
paths;
algorithms = {‘RSA’};
dimension = 20; % (2, 10, 20)
maxFE = 1000; % 1000000
cec2022 = str2func(‘cec22_test_func’);
globalMins = {300, 400, 600, 800, 900, 1800, 2000, 2200, 2300, 2400, 2600, 2700};
experimentNumber = 1; run = 21;
filename = ‘result-‘;
functionsNumber = 12;
global count;
solution = zeros(experimentNumber, functionsNumber, run);
solutionR = zeros(functionsNumber * experimentNumber, run);
for ii = 1 : length(algorithms)
disp(algorithms(ii));
algorithm = str2func(char(algorithms(ii)));
for i = 1 : functionsNumber
disp(i);
for j = 1 : run
[~, bestFitness, ~] = algorithm(cec2022, dimension, maxFE, i);
disp(count);
count = 0;
solution(1, i, j) = bestFitness – globalMins{i};
for k = 1 : experimentNumber
solutionR(k + experimentNumber * (i – 1), j) = solution(k, i, j);
end
end
end
xlswrite(strcat(filename, func2str(algorithm), ‘-d=’, num2str(dimension), ‘.xlsx’), solutionR, 1);
eD = strcat(func2str(algorithm), ‘-Bitti :)’);
disp(eD);
end
I’ve tried this code with my friends Winodws Laptop. We both have just dowloaded Matlab so there is no configuration file for both sides. Error is:
Unrecognized function or variable ‘cec22_test_func’.
Error in testFunction (line 29)
fitness = feval(fhd, x, fNumber);
Error in RSA (line 25)
Ffun(1,i)=testFunction(X(i,:)’, fhd, fNumber);
Error in main (line 21)
[~, bestFitness, ~] = algorithm(cec2022, dimension, maxFE, i);
My friend runs this codes with no issue. I literally have no idea what’s happening…paths;
algorithms = {‘RSA’};
dimension = 20; % (2, 10, 20)
maxFE = 1000; % 1000000
cec2022 = str2func(‘cec22_test_func’);
globalMins = {300, 400, 600, 800, 900, 1800, 2000, 2200, 2300, 2400, 2600, 2700};
experimentNumber = 1; run = 21;
filename = ‘result-‘;
functionsNumber = 12;
global count;
solution = zeros(experimentNumber, functionsNumber, run);
solutionR = zeros(functionsNumber * experimentNumber, run);
for ii = 1 : length(algorithms)
disp(algorithms(ii));
algorithm = str2func(char(algorithms(ii)));
for i = 1 : functionsNumber
disp(i);
for j = 1 : run
[~, bestFitness, ~] = algorithm(cec2022, dimension, maxFE, i);
disp(count);
count = 0;
solution(1, i, j) = bestFitness – globalMins{i};
for k = 1 : experimentNumber
solutionR(k + experimentNumber * (i – 1), j) = solution(k, i, j);
end
end
end
xlswrite(strcat(filename, func2str(algorithm), ‘-d=’, num2str(dimension), ‘.xlsx’), solutionR, 1);
eD = strcat(func2str(algorithm), ‘-Bitti :)’);
disp(eD);
end
I’ve tried this code with my friends Winodws Laptop. We both have just dowloaded Matlab so there is no configuration file for both sides. Error is:
Unrecognized function or variable ‘cec22_test_func’.
Error in testFunction (line 29)
fitness = feval(fhd, x, fNumber);
Error in RSA (line 25)
Ffun(1,i)=testFunction(X(i,:)’, fhd, fNumber);
Error in main (line 21)
[~, bestFitness, ~] = algorithm(cec2022, dimension, maxFE, i);
My friend runs this codes with no issue. I literally have no idea what’s happening… paths;
algorithms = {‘RSA’};
dimension = 20; % (2, 10, 20)
maxFE = 1000; % 1000000
cec2022 = str2func(‘cec22_test_func’);
globalMins = {300, 400, 600, 800, 900, 1800, 2000, 2200, 2300, 2400, 2600, 2700};
experimentNumber = 1; run = 21;
filename = ‘result-‘;
functionsNumber = 12;
global count;
solution = zeros(experimentNumber, functionsNumber, run);
solutionR = zeros(functionsNumber * experimentNumber, run);
for ii = 1 : length(algorithms)
disp(algorithms(ii));
algorithm = str2func(char(algorithms(ii)));
for i = 1 : functionsNumber
disp(i);
for j = 1 : run
[~, bestFitness, ~] = algorithm(cec2022, dimension, maxFE, i);
disp(count);
count = 0;
solution(1, i, j) = bestFitness – globalMins{i};
for k = 1 : experimentNumber
solutionR(k + experimentNumber * (i – 1), j) = solution(k, i, j);
end
end
end
xlswrite(strcat(filename, func2str(algorithm), ‘-d=’, num2str(dimension), ‘.xlsx’), solutionR, 1);
eD = strcat(func2str(algorithm), ‘-Bitti :)’);
disp(eD);
end
I’ve tried this code with my friends Winodws Laptop. We both have just dowloaded Matlab so there is no configuration file for both sides. Error is:
Unrecognized function or variable ‘cec22_test_func’.
Error in testFunction (line 29)
fitness = feval(fhd, x, fNumber);
Error in RSA (line 25)
Ffun(1,i)=testFunction(X(i,:)’, fhd, fNumber);
Error in main (line 21)
[~, bestFitness, ~] = algorithm(cec2022, dimension, maxFE, i);
My friend runs this codes with no issue. I literally have no idea what’s happening… mac, error, apple, silicon, windows MATLAB Answers — New Questions
Fuzzy control problem:(1)input 2 expects a value in range [-1.5 1.5], but has a value of 4.36559e+24;
In ‘EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller’, input 2 expects a value in range [-1.5 1.5], but has a value of 4.36559e+24.
取消组合 1025 相似
显示堆栈跟踪
组件:Simulink | 类别:Model 警告
In ‘EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller’, no rules fired for Output 1. Defuzzified output value set to its mean range value 0.
取消组合 3075 相似In ‘EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller’, input 2 expects a value in range [-1.5 1.5], but has a value of 4.36559e+24.
取消组合 1025 相似
显示堆栈跟踪
组件:Simulink | 类别:Model 警告
In ‘EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller’, no rules fired for Output 1. Defuzzified output value set to its mean range value 0.
取消组合 3075 相似 In ‘EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller’, input 2 expects a value in range [-1.5 1.5], but has a value of 4.36559e+24.
取消组合 1025 相似
显示堆栈跟踪
组件:Simulink | 类别:Model 警告
In ‘EV_Thermal_Management_wendukongzhi_zhileng/Controls/Compressor Control/ÿÿÿÿ/Fuzzy Logic
Controller’, no rules fired for Output 1. Defuzzified output value set to its mean range value 0.
取消组合 3075 相似 fuzzy control, pid MATLAB Answers — New Questions
I am unable to find the minimum value of function f in this optimization problem. The solver always returns 0 for all variables which is not possible. I am unable to correct.
A=[ -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1];
lb=zeros(45,1);
ub=[];
b = [12080409 1298550 1347885 12093180 16779807 9015369 30515991 12545445 11203005 9049854 30442401 16253193 21471318 29855661 8079324 267300000 213840000 588060000];
f = [0.0969 0.1236 0.0485 0.0267 0.0776 0.1164 0.6012 0.24 0.3297 0.1419 0.4388 0.5319 0.8969 0.1503 0.2448 0.2691 0.2909 0.223 0.1769 0.2206 0.0703 0.7661 0.3952 0.5067 0.5745 0.5915 0.6642 1.0206 0.3055 0.4097 0.3079 0.2182 0.2352 0.2618 0.2982 0.3952 0.4024 0.3467 0.0399 0.2618 0.19880 0.1212 1.24 0.1673 0.3103];
x = linprog(f,A,b, [], [], lb, ub)A=[ -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -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1 1 1 1];
lb=zeros(45,1);
ub=[];
b = [12080409 1298550 1347885 12093180 16779807 9015369 30515991 12545445 11203005 9049854 30442401 16253193 21471318 29855661 8079324 267300000 213840000 588060000];
f = [0.0969 0.1236 0.0485 0.0267 0.0776 0.1164 0.6012 0.24 0.3297 0.1419 0.4388 0.5319 0.8969 0.1503 0.2448 0.2691 0.2909 0.223 0.1769 0.2206 0.0703 0.7661 0.3952 0.5067 0.5745 0.5915 0.6642 1.0206 0.3055 0.4097 0.3079 0.2182 0.2352 0.2618 0.2982 0.3952 0.4024 0.3467 0.0399 0.2618 0.19880 0.1212 1.24 0.1673 0.3103];
x = linprog(f,A,b, [], [], lb, ub) A=[ -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 -1 0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550 1347885 12093180 16779807 9015369 30515991 12545445 11203005 9049854 30442401 16253193 21471318 29855661 8079324 267300000 213840000 588060000];
f = [0.0969 0.1236 0.0485 0.0267 0.0776 0.1164 0.6012 0.24 0.3297 0.1419 0.4388 0.5319 0.8969 0.1503 0.2448 0.2691 0.2909 0.223 0.1769 0.2206 0.0703 0.7661 0.3952 0.5067 0.5745 0.5915 0.6642 1.0206 0.3055 0.4097 0.3079 0.2182 0.2352 0.2618 0.2982 0.3952 0.4024 0.3467 0.0399 0.2618 0.19880 0.1212 1.24 0.1673 0.3103];
x = linprog(f,A,b, [], [], lb, ub) optimization, matlab MATLAB Answers — New Questions
Run in parallel a script and a real-time simulation
Hi everyone!
I will try to explain myself as clear as possible so that you can understand the problem I am facing right now, which maybe has been already solved, in which case I apologize.
I am running a Real-time Simulink Model (very simple one, a sine wave with a gain whose parameter is a variable, ‘x1’)
I want to change the ‘x1’ parameter from the gain block ‘G1’ during the simulation but the main problem I am encountering is that the simulation stops until the scripts ends and it is not simultaneous.
So my question is the following: Is it possible to run a script and a simulink model at the same time so that the variables from the script are fed into the simulink model as block parameters?
Thank you so much!
Kind regards,
EduardoHi everyone!
I will try to explain myself as clear as possible so that you can understand the problem I am facing right now, which maybe has been already solved, in which case I apologize.
I am running a Real-time Simulink Model (very simple one, a sine wave with a gain whose parameter is a variable, ‘x1’)
I want to change the ‘x1’ parameter from the gain block ‘G1’ during the simulation but the main problem I am encountering is that the simulation stops until the scripts ends and it is not simultaneous.
So my question is the following: Is it possible to run a script and a simulink model at the same time so that the variables from the script are fed into the simulink model as block parameters?
Thank you so much!
Kind regards,
Eduardo Hi everyone!
I will try to explain myself as clear as possible so that you can understand the problem I am facing right now, which maybe has been already solved, in which case I apologize.
I am running a Real-time Simulink Model (very simple one, a sine wave with a gain whose parameter is a variable, ‘x1’)
I want to change the ‘x1’ parameter from the gain block ‘G1’ during the simulation but the main problem I am encountering is that the simulation stops until the scripts ends and it is not simultaneous.
So my question is the following: Is it possible to run a script and a simulink model at the same time so that the variables from the script are fed into the simulink model as block parameters?
Thank you so much!
Kind regards,
Eduardo real-time sync, parallel operation, script and simulink MATLAB Answers — New Questions
HELLO PLEASE HELP ME
I am from Armenia Master degree 1st course. I am very poor in Matlab. Please help me with my course work. my exercise is`
solve equation and then compare with simulink
equation is` y””+y”’-y”-y’=2x+2sinx
y= c1+c2e^-x+c3x^e-x+c4^ex+2x-x^2-0.5(sin x +cos x)I am from Armenia Master degree 1st course. I am very poor in Matlab. Please help me with my course work. my exercise is`
solve equation and then compare with simulink
equation is` y””+y”’-y”-y’=2x+2sinx
y= c1+c2e^-x+c3x^e-x+c4^ex+2x-x^2-0.5(sin x +cos x) I am from Armenia Master degree 1st course. I am very poor in Matlab. Please help me with my course work. my exercise is`
solve equation and then compare with simulink
equation is` y””+y”’-y”-y’=2x+2sinx
y= c1+c2e^-x+c3x^e-x+c4^ex+2x-x^2-0.5(sin x +cos x) matlab, simulink, differential equations MATLAB Answers — New Questions
Is it possible to make MatlabEngine class object persistent in Java?
Dear Matlab specialists!
My colleague wrote a simple Java class (code below) to create and use MatlabEngine "eng" object in the run() function. It works normally.
However, when one makes this object a member of class and then tries to reuse it, it looks like the whole associated Matlab session disappears after the first usage.
I am intersted in creating MatlabEngine object/session "eng" in a way when it is possible to call it from other Java classes for which the Java class where it is created, is visible. In particular, I’d like to create a Matlab class object within "eng", make some setups (which need quite long calculations), and then call the "Do(current_data)" function of this created Matlab class on my current data, i.e. whenever/wherever needed in Java. For that obviously, this "eng" object and its session should be persistent. So my question is – is it posibble at all?
Best wishes,
Y.
import com.mathworks.engine.EngineException;
import com.mathworks.engine.MatlabEngine;
import com.mathworks.engine.MatlabSyntaxException;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class javaFevalFcnMulti implements Runnable{
String[] args;
int num1;
int num2;
public javaFevalFcnMulti(String[] args_in, int num1_in, int num2_in){
args = args_in;
num1 = num1_in;
num2 = num2_in;
}
@Override
public void run() {
MatlabEngine eng;
try {
System.out.println("MLT started");
eng = MatlabEngine.startMatlab();
Object[] results = eng.feval(3, "gcd", num1, num2);
Integer G = (Integer)results[0];
Integer U = (Integer)results[1];
Integer V = (Integer)results[2];
eng.close();
System.out.println("Greatest common divisor of "+Integer.toString(num1)+" and "+Integer.toString(num2)+" is "+G.toString());
} catch (EngineException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalStateException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (MatlabSyntaxException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (ExecutionException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
}
}
}Dear Matlab specialists!
My colleague wrote a simple Java class (code below) to create and use MatlabEngine "eng" object in the run() function. It works normally.
However, when one makes this object a member of class and then tries to reuse it, it looks like the whole associated Matlab session disappears after the first usage.
I am intersted in creating MatlabEngine object/session "eng" in a way when it is possible to call it from other Java classes for which the Java class where it is created, is visible. In particular, I’d like to create a Matlab class object within "eng", make some setups (which need quite long calculations), and then call the "Do(current_data)" function of this created Matlab class on my current data, i.e. whenever/wherever needed in Java. For that obviously, this "eng" object and its session should be persistent. So my question is – is it posibble at all?
Best wishes,
Y.
import com.mathworks.engine.EngineException;
import com.mathworks.engine.MatlabEngine;
import com.mathworks.engine.MatlabSyntaxException;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class javaFevalFcnMulti implements Runnable{
String[] args;
int num1;
int num2;
public javaFevalFcnMulti(String[] args_in, int num1_in, int num2_in){
args = args_in;
num1 = num1_in;
num2 = num2_in;
}
@Override
public void run() {
MatlabEngine eng;
try {
System.out.println("MLT started");
eng = MatlabEngine.startMatlab();
Object[] results = eng.feval(3, "gcd", num1, num2);
Integer G = (Integer)results[0];
Integer U = (Integer)results[1];
Integer V = (Integer)results[2];
eng.close();
System.out.println("Greatest common divisor of "+Integer.toString(num1)+" and "+Integer.toString(num2)+" is "+G.toString());
} catch (EngineException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalStateException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (MatlabSyntaxException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (ExecutionException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
}
}
} Dear Matlab specialists!
My colleague wrote a simple Java class (code below) to create and use MatlabEngine "eng" object in the run() function. It works normally.
However, when one makes this object a member of class and then tries to reuse it, it looks like the whole associated Matlab session disappears after the first usage.
I am intersted in creating MatlabEngine object/session "eng" in a way when it is possible to call it from other Java classes for which the Java class where it is created, is visible. In particular, I’d like to create a Matlab class object within "eng", make some setups (which need quite long calculations), and then call the "Do(current_data)" function of this created Matlab class on my current data, i.e. whenever/wherever needed in Java. For that obviously, this "eng" object and its session should be persistent. So my question is – is it posibble at all?
Best wishes,
Y.
import com.mathworks.engine.EngineException;
import com.mathworks.engine.MatlabEngine;
import com.mathworks.engine.MatlabSyntaxException;
import java.util.concurrent.ExecutionException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class javaFevalFcnMulti implements Runnable{
String[] args;
int num1;
int num2;
public javaFevalFcnMulti(String[] args_in, int num1_in, int num2_in){
args = args_in;
num1 = num1_in;
num2 = num2_in;
}
@Override
public void run() {
MatlabEngine eng;
try {
System.out.println("MLT started");
eng = MatlabEngine.startMatlab();
Object[] results = eng.feval(3, "gcd", num1, num2);
Integer G = (Integer)results[0];
Integer U = (Integer)results[1];
Integer V = (Integer)results[2];
eng.close();
System.out.println("Greatest common divisor of "+Integer.toString(num1)+" and "+Integer.toString(num2)+" is "+G.toString());
} catch (EngineException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalArgumentException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalStateException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (MatlabSyntaxException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
} catch (ExecutionException ex) {
Logger.getLogger(javaFevalFcnMulti.class.getName()).log(Level.SEVERE, null, ex);
}
}
} matlabengine, java MATLAB Answers — New Questions
Ho can i stop the axtoolbar from hiding?
I want the axtoolbar within a 2D-Plot to be shown always, not only when i put the mouse in the upper right part of the plot. Can this dynamic hiding function be disabled? If there is a solution, would it also work in App Designer?
Regards,
MatthiasI want the axtoolbar within a 2D-Plot to be shown always, not only when i put the mouse in the upper right part of the plot. Can this dynamic hiding function be disabled? If there is a solution, would it also work in App Designer?
Regards,
Matthias I want the axtoolbar within a 2D-Plot to be shown always, not only when i put the mouse in the upper right part of the plot. Can this dynamic hiding function be disabled? If there is a solution, would it also work in App Designer?
Regards,
Matthias axtoolbar, visibility, dynamic, static MATLAB Answers — New Questions
Force scientific notation in axes
Sometimes, when the "raw" values in the yticks are very small, matlab y axis automatically toggles to scientific notation, whereby the power of ten giving the order of magnitude appears in the top left corner, and the yticks are given in units of that power.
The threshold for this behavior seems to be 1e-3, but I can’t seem to find a property for forcing it on larger yticks.
I have found a few questions roughly on the same topic, but none of the relevant answers seem to apply to my case. Some people simply wanted to get rid of the scientific notation, other wanted it directly in the tick labels.
I like the "order of magnitude" format, but I am unable to force it (for instance, I’d like to have it for yticks of the order of 1e-2, for graphical homogeneity with a different plot).
Before downloading or creating an "ad hoc" code, I wanted to ask whether any of you knows a (perhaps undocumented?) way of toggling the "order of magnitude" notation.
Thanks a lot
FrancescoSometimes, when the "raw" values in the yticks are very small, matlab y axis automatically toggles to scientific notation, whereby the power of ten giving the order of magnitude appears in the top left corner, and the yticks are given in units of that power.
The threshold for this behavior seems to be 1e-3, but I can’t seem to find a property for forcing it on larger yticks.
I have found a few questions roughly on the same topic, but none of the relevant answers seem to apply to my case. Some people simply wanted to get rid of the scientific notation, other wanted it directly in the tick labels.
I like the "order of magnitude" format, but I am unable to force it (for instance, I’d like to have it for yticks of the order of 1e-2, for graphical homogeneity with a different plot).
Before downloading or creating an "ad hoc" code, I wanted to ask whether any of you knows a (perhaps undocumented?) way of toggling the "order of magnitude" notation.
Thanks a lot
Francesco Sometimes, when the "raw" values in the yticks are very small, matlab y axis automatically toggles to scientific notation, whereby the power of ten giving the order of magnitude appears in the top left corner, and the yticks are given in units of that power.
The threshold for this behavior seems to be 1e-3, but I can’t seem to find a property for forcing it on larger yticks.
I have found a few questions roughly on the same topic, but none of the relevant answers seem to apply to my case. Some people simply wanted to get rid of the scientific notation, other wanted it directly in the tick labels.
I like the "order of magnitude" format, but I am unable to force it (for instance, I’d like to have it for yticks of the order of 1e-2, for graphical homogeneity with a different plot).
Before downloading or creating an "ad hoc" code, I wanted to ask whether any of you knows a (perhaps undocumented?) way of toggling the "order of magnitude" notation.
Thanks a lot
Francesco axes, ticks, scientific notation MATLAB Answers — New Questions
The write channel is same as read channel data. Why the data is not processed?
We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data?
% Source ThingSpeak Channel ID for reading data
readChannelID = 2522808; % Replace with your source channel ID
% Destination ThingSpeak Channel ID for writing data
writeChannelID = 2522810; % Replace with your destination channel ID
% ThingSpeak Read API Key for the source channel
readAPIKey = ‘XXX’; % Replace with your read API key
% ThingSpeak Write API Key for the destination channel
writeAPIKey = ‘XXX’; % Replace with your write API key
%% Read Data %%
% Read all available data from the source channel
data = thingSpeakRead(readChannelID, ‘ReadKey’, readAPIKey, ‘Fields’, [1, 2]);
% Extract the values from the read data
values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage
values2 = data(:, 2); % Values from field 2 i.e. Input Current
% Determine the number of data points retrieved
numPoints = size(data, 1); % Assign the number of rows in the variable ‘data’ to the variable ‘numPoints’
% Generate timestamps for the data
timeStamps = datetime(‘now’) – minutes(numPoints:-1:1);
% Initialize Y arrays
Y1 = zeros(size(values1)); % Create a new array ‘Y1’ filled with zeros that has same size as the array ‘values1’
Y2 = zeros(size(values2)); % Create a new array ‘Y2’ filled with zeros that has same size as the array ‘values2’
% Perform the operation Y(i) = i * I(i) for each value in the read data
for i = 1:length(values1)
disp([‘Processing index ‘, num2str(i)]);
disp([‘values1(‘, num2str(i), ‘) = ‘, num2str(values1(i))]);
disp([‘values2(‘, num2str(i), ‘) = ‘, num2str(values2(i))]);
Y1(i) = i * values1(i);
Y2(i) = i * values2(i);
disp([‘Y1(‘, num2str(i), ‘) = ‘, num2str(Y1(i))]);
disp([‘Y2(‘, num2str(i), ‘) = ‘, num2str(Y2(i))]);
end
% Write the data to the destination channel with timestamps
thingSpeakWrite(writeChannelID, ‘WriteKey’, writeAPIKey, ‘Values’, [Y1′, Y2′], ‘Fields’, [1, 2], ‘Timestamps’, timeStamps);We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data?
% Source ThingSpeak Channel ID for reading data
readChannelID = 2522808; % Replace with your source channel ID
% Destination ThingSpeak Channel ID for writing data
writeChannelID = 2522810; % Replace with your destination channel ID
% ThingSpeak Read API Key for the source channel
readAPIKey = ‘XXX’; % Replace with your read API key
% ThingSpeak Write API Key for the destination channel
writeAPIKey = ‘XXX’; % Replace with your write API key
%% Read Data %%
% Read all available data from the source channel
data = thingSpeakRead(readChannelID, ‘ReadKey’, readAPIKey, ‘Fields’, [1, 2]);
% Extract the values from the read data
values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage
values2 = data(:, 2); % Values from field 2 i.e. Input Current
% Determine the number of data points retrieved
numPoints = size(data, 1); % Assign the number of rows in the variable ‘data’ to the variable ‘numPoints’
% Generate timestamps for the data
timeStamps = datetime(‘now’) – minutes(numPoints:-1:1);
% Initialize Y arrays
Y1 = zeros(size(values1)); % Create a new array ‘Y1’ filled with zeros that has same size as the array ‘values1’
Y2 = zeros(size(values2)); % Create a new array ‘Y2’ filled with zeros that has same size as the array ‘values2’
% Perform the operation Y(i) = i * I(i) for each value in the read data
for i = 1:length(values1)
disp([‘Processing index ‘, num2str(i)]);
disp([‘values1(‘, num2str(i), ‘) = ‘, num2str(values1(i))]);
disp([‘values2(‘, num2str(i), ‘) = ‘, num2str(values2(i))]);
Y1(i) = i * values1(i);
Y2(i) = i * values2(i);
disp([‘Y1(‘, num2str(i), ‘) = ‘, num2str(Y1(i))]);
disp([‘Y2(‘, num2str(i), ‘) = ‘, num2str(Y2(i))]);
end
% Write the data to the destination channel with timestamps
thingSpeakWrite(writeChannelID, ‘WriteKey’, writeAPIKey, ‘Values’, [Y1′, Y2′], ‘Fields’, [1, 2], ‘Timestamps’, timeStamps); We collect the real time data from read channel and want process it before sending it to write channel, but the data values in the write channel replicate the read channel values for the following code. Could anyone give suggession how to get the processed data?
% Source ThingSpeak Channel ID for reading data
readChannelID = 2522808; % Replace with your source channel ID
% Destination ThingSpeak Channel ID for writing data
writeChannelID = 2522810; % Replace with your destination channel ID
% ThingSpeak Read API Key for the source channel
readAPIKey = ‘XXX’; % Replace with your read API key
% ThingSpeak Write API Key for the destination channel
writeAPIKey = ‘XXX’; % Replace with your write API key
%% Read Data %%
% Read all available data from the source channel
data = thingSpeakRead(readChannelID, ‘ReadKey’, readAPIKey, ‘Fields’, [1, 2]);
% Extract the values from the read data
values1 = data(:, 1); % Values from field 1 i.e. Estimated Voltage
values2 = data(:, 2); % Values from field 2 i.e. Input Current
% Determine the number of data points retrieved
numPoints = size(data, 1); % Assign the number of rows in the variable ‘data’ to the variable ‘numPoints’
% Generate timestamps for the data
timeStamps = datetime(‘now’) – minutes(numPoints:-1:1);
% Initialize Y arrays
Y1 = zeros(size(values1)); % Create a new array ‘Y1’ filled with zeros that has same size as the array ‘values1’
Y2 = zeros(size(values2)); % Create a new array ‘Y2’ filled with zeros that has same size as the array ‘values2’
% Perform the operation Y(i) = i * I(i) for each value in the read data
for i = 1:length(values1)
disp([‘Processing index ‘, num2str(i)]);
disp([‘values1(‘, num2str(i), ‘) = ‘, num2str(values1(i))]);
disp([‘values2(‘, num2str(i), ‘) = ‘, num2str(values2(i))]);
Y1(i) = i * values1(i);
Y2(i) = i * values2(i);
disp([‘Y1(‘, num2str(i), ‘) = ‘, num2str(Y1(i))]);
disp([‘Y2(‘, num2str(i), ‘) = ‘, num2str(Y2(i))]);
end
% Write the data to the destination channel with timestamps
thingSpeakWrite(writeChannelID, ‘WriteKey’, writeAPIKey, ‘Values’, [Y1′, Y2′], ‘Fields’, [1, 2], ‘Timestamps’, timeStamps); thingspeak, read channel, write channel, data processing MATLAB Answers — New Questions
Spli cell array directly at the function output
Hi,
I have a function returning two 1*n cell arrays as output, which I want to append to two existing cell arrays (variable1 and variable2). However, I don’t want to end up with nested cells arrays, so my code looks like this:
variable1 = { ‘var11’, ‘var12’ };
variable2 = { ‘var21’, ‘var22’ };
[ output1, output2 ] = myFunc();
variable1 = [ variable1, output1{:} ];
variable2 = [ variable2, output2{:} ];
In this case, is it possible to append the outputs to variable1 and variable2 and exploding the cells in only one line instead of 3. So something like this (which obviously does not work but it is just to be sure I am clear enough):
variable1 = { ‘var11’, ‘var12’ };
variable2 = { ‘var21’, ‘var22’ };
[ [ variable1, output1{:} ], [ variable2, output2{:} ] ] = myFunc();
Thanks for your help.Hi,
I have a function returning two 1*n cell arrays as output, which I want to append to two existing cell arrays (variable1 and variable2). However, I don’t want to end up with nested cells arrays, so my code looks like this:
variable1 = { ‘var11’, ‘var12’ };
variable2 = { ‘var21’, ‘var22’ };
[ output1, output2 ] = myFunc();
variable1 = [ variable1, output1{:} ];
variable2 = [ variable2, output2{:} ];
In this case, is it possible to append the outputs to variable1 and variable2 and exploding the cells in only one line instead of 3. So something like this (which obviously does not work but it is just to be sure I am clear enough):
variable1 = { ‘var11’, ‘var12’ };
variable2 = { ‘var21’, ‘var22’ };
[ [ variable1, output1{:} ], [ variable2, output2{:} ] ] = myFunc();
Thanks for your help. Hi,
I have a function returning two 1*n cell arrays as output, which I want to append to two existing cell arrays (variable1 and variable2). However, I don’t want to end up with nested cells arrays, so my code looks like this:
variable1 = { ‘var11’, ‘var12’ };
variable2 = { ‘var21’, ‘var22’ };
[ output1, output2 ] = myFunc();
variable1 = [ variable1, output1{:} ];
variable2 = [ variable2, output2{:} ];
In this case, is it possible to append the outputs to variable1 and variable2 and exploding the cells in only one line instead of 3. So something like this (which obviously does not work but it is just to be sure I am clear enough):
variable1 = { ‘var11’, ‘var12’ };
variable2 = { ‘var21’, ‘var22’ };
[ [ variable1, output1{:} ], [ variable2, output2{:} ] ] = myFunc();
Thanks for your help. cell array, function MATLAB Answers — New Questions