Category: Matlab
Category Archives: Matlab
matlab simulink 대수루프 해결방법 문의
수소 탱크를 충전할 때 압력이 상승하여 탱크 내 온도가 상승하는데 외부로 열전달 현상을 통해서 열이 빠져나간다.
수소 탱크에 수소가 유입이 될 때 압력, 온도, 질량유량에 따라 내부 열전달 계수를 계산하고 반영해서 탱크에서의 온도를 예측하는 모델을 만들고 있는데 루프가 걸려서
블록 다이어그램 ‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’에 1개의 대수 루프가 있습니다. 루프에 대한 자세한 내용을 보려면 명령 Simulink.BlockDiagram.getAlgebraicLoops(‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’)을(를) 사용하거나 MATLAB 명령 창에 sldebug(‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’)을(를) 입력하여 명령줄 Simulink 디버거를 사용하십시오. 이 메시지를 제거하려면 대수 루프를 "안 함"으로 설정하십시오.
구성요소:Simulink | 범주:Block diagram 경고
다음이 포함된 대수 루프가 발견됨: Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Power1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Sum1 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /PowerInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Sum2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product5Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/PowerInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/LogInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Log1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product3Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/SquareInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/GainInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /SumInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product3Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ProductInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/INPUT_1_1_1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/STATE_1 (discontinuity) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/OUTPUT_1_0Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Math FunctionInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/GainInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Math Function1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /k/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Cp/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Cp/ProductInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /mu/Gain1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product6 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /mu/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /rho/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /rho/Gain1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product4Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product5 (algebraic variable)
구성요소:Simulink | 범주:Model
대수 루프 내에서 불연속이 감지되었습니다. 해를 구하는 데 어려움이 있을 수 있습니다.
구성요소:Simulink | 범주:Model 경고
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product5’에 0으로 나누기 발생
구성요소:Simulink | 범주:Block 경고
표시 안 함
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Power’에 거듭제곱 결과가 정의되어 있지 않습니다.
구성요소:Simulink | 범주:Block 경고
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product1’에 0으로 나누기 발생
구성요소:Simulink | 범주:Block 경고
표시 안 함
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Log1’에 음수의 로그가 있습니다. ‘출력 신호 유형’을 복소수로 설정해 보십시오.
구성요소:Simulink | 범주:Block 경고
시뮬레이션을 실행하는 동안 오류가 발생하여 시뮬레이션이 종료되었습니다
원인:
시간 0.0에 계산된 ‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product’을(를) 포함하는 대수 루프의 대수 상태가 Inf 또는 NaN입니다. 해에 특이점이 있을 수 있습니다. 모델이 올바른 경우 고정 스텝 크기를 줄이거나 오차 허용오차를 좁혀 스텝 크기를 줄여 보십시오. 또는 대수 루프 변수 값의 초기 추측값을 조금 수정하십시오.
다음과 같은 오류가 뜬다.
압력과 온도는 물성값 구하기 위해 필요하고 질량유량은 Renolds number를 구하기 위해 필요하다.
Liner Thermal Mass, CFRP Thermal Mass, External Convective Heat Transfer, CFRP Conductive Heat Transfer 등등 블럭은 고정된 값을 사용해서 신경 안써도될 것 같다.
아래 사진은 simulink 설계도이다.수소 탱크를 충전할 때 압력이 상승하여 탱크 내 온도가 상승하는데 외부로 열전달 현상을 통해서 열이 빠져나간다.
수소 탱크에 수소가 유입이 될 때 압력, 온도, 질량유량에 따라 내부 열전달 계수를 계산하고 반영해서 탱크에서의 온도를 예측하는 모델을 만들고 있는데 루프가 걸려서
블록 다이어그램 ‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’에 1개의 대수 루프가 있습니다. 루프에 대한 자세한 내용을 보려면 명령 Simulink.BlockDiagram.getAlgebraicLoops(‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’)을(를) 사용하거나 MATLAB 명령 창에 sldebug(‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’)을(를) 입력하여 명령줄 Simulink 디버거를 사용하십시오. 이 메시지를 제거하려면 대수 루프를 "안 함"으로 설정하십시오.
구성요소:Simulink | 범주:Block diagram 경고
다음이 포함된 대수 루프가 발견됨: Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Power1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Sum1 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /PowerInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Sum2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product5Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/PowerInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/LogInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Log1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product3Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/SquareInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/GainInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /SumInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product3Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ProductInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/INPUT_1_1_1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/STATE_1 (discontinuity) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/OUTPUT_1_0Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Math FunctionInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/GainInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Math Function1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /k/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Cp/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Cp/ProductInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /mu/Gain1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product6 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /mu/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /rho/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /rho/Gain1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product4Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product5 (algebraic variable)
구성요소:Simulink | 범주:Model
대수 루프 내에서 불연속이 감지되었습니다. 해를 구하는 데 어려움이 있을 수 있습니다.
구성요소:Simulink | 범주:Model 경고
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product5’에 0으로 나누기 발생
구성요소:Simulink | 범주:Block 경고
표시 안 함
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Power’에 거듭제곱 결과가 정의되어 있지 않습니다.
구성요소:Simulink | 범주:Block 경고
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product1’에 0으로 나누기 발생
구성요소:Simulink | 범주:Block 경고
표시 안 함
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Log1’에 음수의 로그가 있습니다. ‘출력 신호 유형’을 복소수로 설정해 보십시오.
구성요소:Simulink | 범주:Block 경고
시뮬레이션을 실행하는 동안 오류가 발생하여 시뮬레이션이 종료되었습니다
원인:
시간 0.0에 계산된 ‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product’을(를) 포함하는 대수 루프의 대수 상태가 Inf 또는 NaN입니다. 해에 특이점이 있을 수 있습니다. 모델이 올바른 경우 고정 스텝 크기를 줄이거나 오차 허용오차를 좁혀 스텝 크기를 줄여 보십시오. 또는 대수 루프 변수 값의 초기 추측값을 조금 수정하십시오.
다음과 같은 오류가 뜬다.
압력과 온도는 물성값 구하기 위해 필요하고 질량유량은 Renolds number를 구하기 위해 필요하다.
Liner Thermal Mass, CFRP Thermal Mass, External Convective Heat Transfer, CFRP Conductive Heat Transfer 등등 블럭은 고정된 값을 사용해서 신경 안써도될 것 같다.
아래 사진은 simulink 설계도이다. 수소 탱크를 충전할 때 압력이 상승하여 탱크 내 온도가 상승하는데 외부로 열전달 현상을 통해서 열이 빠져나간다.
수소 탱크에 수소가 유입이 될 때 압력, 온도, 질량유량에 따라 내부 열전달 계수를 계산하고 반영해서 탱크에서의 온도를 예측하는 모델을 만들고 있는데 루프가 걸려서
블록 다이어그램 ‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’에 1개의 대수 루프가 있습니다. 루프에 대한 자세한 내용을 보려면 명령 Simulink.BlockDiagram.getAlgebraicLoops(‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’)을(를) 사용하거나 MATLAB 명령 창에 sldebug(‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b’)을(를) 입력하여 명령줄 Simulink 디버거를 사용하십시오. 이 메시지를 제거하려면 대수 루프를 "안 함"으로 설정하십시오.
구성요소:Simulink | 범주:Block diagram 경고
다음이 포함된 대수 루프가 발견됨: Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Power1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Sum1 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /PowerInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Sum2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product5Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/PowerInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/LogInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Log1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product2Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product3Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/SquareInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/GainInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /SumInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product3Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ProductInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/INPUT_1_1_1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/STATE_1 (discontinuity) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/Solver Configuration/EVAL_KEY/OUTPUT_1_0Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Math FunctionInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/GainInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Math Function1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /k/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Cp/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Cp/ProductInternal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /mu/Gain1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product6 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /mu/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /rho/Product7 (algebraic variable) Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /rho/Gain1Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product4Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product5 (algebraic variable)
구성요소:Simulink | 범주:Model
대수 루프 내에서 불연속이 감지되었습니다. 해를 구하는 데 어려움이 있을 수 있습니다.
구성요소:Simulink | 범주:Model 경고
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product5’에 0으로 나누기 발생
구성요소:Simulink | 범주:Block 경고
표시 안 함
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Power’에 거듭제곱 결과가 정의되어 있지 않습니다.
구성요소:Simulink | 범주:Block 경고
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Product1’에 0으로 나누기 발생
구성요소:Simulink | 범주:Block 경고
표시 안 함
‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Subsystem/Log1’에 음수의 로그가 있습니다. ‘출력 신호 유형’을 복소수로 설정해 보십시오.
구성요소:Simulink | 범주:Block 경고
시뮬레이션을 실행하는 동안 오류가 발생하여 시뮬레이션이 종료되었습니다
원인:
시간 0.0에 계산된 ‘Internal_Heat_Trasfer_Coefficient_Test_ver1_2023b/Subsystem/ /Product’을(를) 포함하는 대수 루프의 대수 상태가 Inf 또는 NaN입니다. 해에 특이점이 있을 수 있습니다. 모델이 올바른 경우 고정 스텝 크기를 줄이거나 오차 허용오차를 좁혀 스텝 크기를 줄여 보십시오. 또는 대수 루프 변수 값의 초기 추측값을 조금 수정하십시오.
다음과 같은 오류가 뜬다.
압력과 온도는 물성값 구하기 위해 필요하고 질량유량은 Renolds number를 구하기 위해 필요하다.
Liner Thermal Mass, CFRP Thermal Mass, External Convective Heat Transfer, CFRP Conductive Heat Transfer 등등 블럭은 고정된 값을 사용해서 신경 안써도될 것 같다.
아래 사진은 simulink 설계도이다. 수소충전, simulink, 대수루프 MATLAB Answers — New Questions
Debugging: Changing ode equation during integration
Hello everyone,
I’m imprementing an adjustment to my chemical reactor design regarding physical limitation, due to the kinetics the value of one specie goes negative (comuptationally correct, but not physically) to account for the "no more fuel no more reaction" scenario i introduced a if:
ReactionRate(2*ovr) = ReactionK(2)*C(4)* 1e6 /CatalystDensity; % kmol/kgcat/h
if y(ovr) < 0
ReactionRate(2*ovr) = 0; % kmol/kgcat/h
end
dydt(i) = NetRateProduction(i)*(1-VoidFraction)*CatalystDensity*mw(i)/G;
in this way the dydt=0 and the value after reaching 0 (or a small negligible negative value) should stay constant, but after integration i still see a trend that goes way past 0
-0.0978571895684889
-0.0978554762967198
-0.0978537439506636
-0.0978519924638089
since the Ode for this specie depends only on the ReactionRate if dydt+0 it should stay constant, or is an error due to the fact that to evaluate if the rate should be 0 or not i use y? i tried with the last value of y using the persistent variable
persistent y_prev
.
if y_prev(ovr) < 0
ReactionRate(2*ovr) = 0; % kmol/kgcat/h
end
%after the system of ODE
y_prev(ovr) = y(ovr)
how this happens? i tested with de-bugging to see if the Ode=0 if the condition on y is satisfied and eas zero, so a constant behaviour, but in the results the diminishing trend is still present.
Thank you so much for your helpHello everyone,
I’m imprementing an adjustment to my chemical reactor design regarding physical limitation, due to the kinetics the value of one specie goes negative (comuptationally correct, but not physically) to account for the "no more fuel no more reaction" scenario i introduced a if:
ReactionRate(2*ovr) = ReactionK(2)*C(4)* 1e6 /CatalystDensity; % kmol/kgcat/h
if y(ovr) < 0
ReactionRate(2*ovr) = 0; % kmol/kgcat/h
end
dydt(i) = NetRateProduction(i)*(1-VoidFraction)*CatalystDensity*mw(i)/G;
in this way the dydt=0 and the value after reaching 0 (or a small negligible negative value) should stay constant, but after integration i still see a trend that goes way past 0
-0.0978571895684889
-0.0978554762967198
-0.0978537439506636
-0.0978519924638089
since the Ode for this specie depends only on the ReactionRate if dydt+0 it should stay constant, or is an error due to the fact that to evaluate if the rate should be 0 or not i use y? i tried with the last value of y using the persistent variable
persistent y_prev
.
if y_prev(ovr) < 0
ReactionRate(2*ovr) = 0; % kmol/kgcat/h
end
%after the system of ODE
y_prev(ovr) = y(ovr)
how this happens? i tested with de-bugging to see if the Ode=0 if the condition on y is satisfied and eas zero, so a constant behaviour, but in the results the diminishing trend is still present.
Thank you so much for your help Hello everyone,
I’m imprementing an adjustment to my chemical reactor design regarding physical limitation, due to the kinetics the value of one specie goes negative (comuptationally correct, but not physically) to account for the "no more fuel no more reaction" scenario i introduced a if:
ReactionRate(2*ovr) = ReactionK(2)*C(4)* 1e6 /CatalystDensity; % kmol/kgcat/h
if y(ovr) < 0
ReactionRate(2*ovr) = 0; % kmol/kgcat/h
end
dydt(i) = NetRateProduction(i)*(1-VoidFraction)*CatalystDensity*mw(i)/G;
in this way the dydt=0 and the value after reaching 0 (or a small negligible negative value) should stay constant, but after integration i still see a trend that goes way past 0
-0.0978571895684889
-0.0978554762967198
-0.0978537439506636
-0.0978519924638089
since the Ode for this specie depends only on the ReactionRate if dydt+0 it should stay constant, or is an error due to the fact that to evaluate if the rate should be 0 or not i use y? i tried with the last value of y using the persistent variable
persistent y_prev
.
if y_prev(ovr) < 0
ReactionRate(2*ovr) = 0; % kmol/kgcat/h
end
%after the system of ODE
y_prev(ovr) = y(ovr)
how this happens? i tested with de-bugging to see if the Ode=0 if the condition on y is satisfied and eas zero, so a constant behaviour, but in the results the diminishing trend is still present.
Thank you so much for your help ode, if statement MATLAB Answers — New Questions
Histogram with normal distribution curve
Hello,
I have the data x and want to plot it in a histogram with the number of observations on the y-axis. I want to show also the normal distributon curve overlaying the histogram. I define V = 0:0.25:7 to the define the edges of the bins. I would like to create several histogram of different data sets with the same bin edges.
Using "hisfit" you cannot define a vector for the bin_edges only the number of bins.
Code
x = data1;
V = [0:0.25:7];
figure(1)
hisfit(x, 20, ‘normal’)
Using "histogram" you can define the edges but when I want to show the normal distribtuion curve I only manage to show it with the probability density.
Code
x = data1;
V = [0:0.25:7];
mu = mean(x);
sig = std(x);
x_normalized = linspace(min(V), max(V));
y_normalized = normpdf(x_normalized, mu, sig);
figure(1)
histogram(x, V, ‘Normalization’, ‘pdf’)
hold on;
plot(x_normalized, y_normalized, ‘r’, ‘LineWidth’, 2);
Is there a possibility to plot the data in a histogram with the normal distribtuion curve with a define bin_width and number of observations on the y-axis?
ThanksHello,
I have the data x and want to plot it in a histogram with the number of observations on the y-axis. I want to show also the normal distributon curve overlaying the histogram. I define V = 0:0.25:7 to the define the edges of the bins. I would like to create several histogram of different data sets with the same bin edges.
Using "hisfit" you cannot define a vector for the bin_edges only the number of bins.
Code
x = data1;
V = [0:0.25:7];
figure(1)
hisfit(x, 20, ‘normal’)
Using "histogram" you can define the edges but when I want to show the normal distribtuion curve I only manage to show it with the probability density.
Code
x = data1;
V = [0:0.25:7];
mu = mean(x);
sig = std(x);
x_normalized = linspace(min(V), max(V));
y_normalized = normpdf(x_normalized, mu, sig);
figure(1)
histogram(x, V, ‘Normalization’, ‘pdf’)
hold on;
plot(x_normalized, y_normalized, ‘r’, ‘LineWidth’, 2);
Is there a possibility to plot the data in a histogram with the normal distribtuion curve with a define bin_width and number of observations on the y-axis?
Thanks Hello,
I have the data x and want to plot it in a histogram with the number of observations on the y-axis. I want to show also the normal distributon curve overlaying the histogram. I define V = 0:0.25:7 to the define the edges of the bins. I would like to create several histogram of different data sets with the same bin edges.
Using "hisfit" you cannot define a vector for the bin_edges only the number of bins.
Code
x = data1;
V = [0:0.25:7];
figure(1)
hisfit(x, 20, ‘normal’)
Using "histogram" you can define the edges but when I want to show the normal distribtuion curve I only manage to show it with the probability density.
Code
x = data1;
V = [0:0.25:7];
mu = mean(x);
sig = std(x);
x_normalized = linspace(min(V), max(V));
y_normalized = normpdf(x_normalized, mu, sig);
figure(1)
histogram(x, V, ‘Normalization’, ‘pdf’)
hold on;
plot(x_normalized, y_normalized, ‘r’, ‘LineWidth’, 2);
Is there a possibility to plot the data in a histogram with the normal distribtuion curve with a define bin_width and number of observations on the y-axis?
Thanks histogram, histfit MATLAB Answers — New Questions
Howto build VNC and Browser mode into matlab docker container?
Ich cannot use the prebuilt matlab docker container as I need to provide my username to our license server. Is there any way to force the pre-built container to use a specific user name for license checkout?
When I rebuild a container using the provided Dockerfile from matlab-dockerfile to incorporate my username I am unable to use -vnc or -browser. Which packages do I have to include to get these features included? I could not find this documented anywhere. Is the Dockerfile that was used for building the prebuilt container available somewhere?
Thanks for your support.Ich cannot use the prebuilt matlab docker container as I need to provide my username to our license server. Is there any way to force the pre-built container to use a specific user name for license checkout?
When I rebuild a container using the provided Dockerfile from matlab-dockerfile to incorporate my username I am unable to use -vnc or -browser. Which packages do I have to include to get these features included? I could not find this documented anywhere. Is the Dockerfile that was used for building the prebuilt container available somewhere?
Thanks for your support. Ich cannot use the prebuilt matlab docker container as I need to provide my username to our license server. Is there any way to force the pre-built container to use a specific user name for license checkout?
When I rebuild a container using the provided Dockerfile from matlab-dockerfile to incorporate my username I am unable to use -vnc or -browser. Which packages do I have to include to get these features included? I could not find this documented anywhere. Is the Dockerfile that was used for building the prebuilt container available somewhere?
Thanks for your support. docker, container, dockerfile MATLAB Answers — New Questions
How to make a curve fill the whole plotspace
Vb0_vec = [10 1000];
mb_vec = (20*10^-3)*(36*pi*Vb0_vec.^2).^(1/3);
rhog0 = 0.169;
lambda = 0.0173;
y = linspace(0, 120000, 50000);
% plot 3: beperkende factor voor capaciteit
W_10 = Capaciteit(y, Vb0_vec(1), lambda, mb_vec(1), rhog0);
W_1000 = Capaciteit(y, Vb0_vec(2), lambda, mb_vec(2), rhog0);
figure(3)
loglog(y, W_10)
hold on
loglog(y, W_1000)
hold off
The output looks like this:
How can i make the curves cover the whole plot (touching both axes)?Vb0_vec = [10 1000];
mb_vec = (20*10^-3)*(36*pi*Vb0_vec.^2).^(1/3);
rhog0 = 0.169;
lambda = 0.0173;
y = linspace(0, 120000, 50000);
% plot 3: beperkende factor voor capaciteit
W_10 = Capaciteit(y, Vb0_vec(1), lambda, mb_vec(1), rhog0);
W_1000 = Capaciteit(y, Vb0_vec(2), lambda, mb_vec(2), rhog0);
figure(3)
loglog(y, W_10)
hold on
loglog(y, W_1000)
hold off
The output looks like this:
How can i make the curves cover the whole plot (touching both axes)? Vb0_vec = [10 1000];
mb_vec = (20*10^-3)*(36*pi*Vb0_vec.^2).^(1/3);
rhog0 = 0.169;
lambda = 0.0173;
y = linspace(0, 120000, 50000);
% plot 3: beperkende factor voor capaciteit
W_10 = Capaciteit(y, Vb0_vec(1), lambda, mb_vec(1), rhog0);
W_1000 = Capaciteit(y, Vb0_vec(2), lambda, mb_vec(2), rhog0);
figure(3)
loglog(y, W_10)
hold on
loglog(y, W_1000)
hold off
The output looks like this:
How can i make the curves cover the whole plot (touching both axes)? filling plot MATLAB Answers — New Questions
How to split a table into multiple tables based on value in a column?
Hello,
I am reading in an excel file that has 2 columns of data. One of them has a lot number and the other has row/col numbers.
I’ve made a table that holds this information, however, I would like to make multiple tables for every set of lot numbers.
I’ve attached an example excel sheet. In this example there are 2 different lot numbers, so I would need it to make 2 different tables for each lot number with each corresponding row, col number! I also need it to be able to adjust if there are more than 2 different lot numbers because the sheet is always updated.
Thanks!Hello,
I am reading in an excel file that has 2 columns of data. One of them has a lot number and the other has row/col numbers.
I’ve made a table that holds this information, however, I would like to make multiple tables for every set of lot numbers.
I’ve attached an example excel sheet. In this example there are 2 different lot numbers, so I would need it to make 2 different tables for each lot number with each corresponding row, col number! I also need it to be able to adjust if there are more than 2 different lot numbers because the sheet is always updated.
Thanks! Hello,
I am reading in an excel file that has 2 columns of data. One of them has a lot number and the other has row/col numbers.
I’ve made a table that holds this information, however, I would like to make multiple tables for every set of lot numbers.
I’ve attached an example excel sheet. In this example there are 2 different lot numbers, so I would need it to make 2 different tables for each lot number with each corresponding row, col number! I also need it to be able to adjust if there are more than 2 different lot numbers because the sheet is always updated.
Thanks! matlab, excel MATLAB Answers — New Questions
any option as applying while code to develop pipeline connection within looped network; has noted zero indexing
Post Content Post Content thingspeak MATLAB Answers — New Questions
Listener not responding to ui slider
I didn’t like how the normal callback implementation on the slider only updated once I stop dragging it, so I tried addlistener instead, but for some reason it just doesn’t respond at all. As a simple example, for the following code
sld = uicontrol(‘Style’,’slider’);
lst = addlistener(sld,’Value’,’PostSet’,@(src,evt)disp(‘value changed’));
Changing the value of the slider directly from the Command Window ( sld.Value=0.5; ) causes the callback function to run, but moving the slider or pressing the arrows on its ends does nothing.
What am I doing wrong?I didn’t like how the normal callback implementation on the slider only updated once I stop dragging it, so I tried addlistener instead, but for some reason it just doesn’t respond at all. As a simple example, for the following code
sld = uicontrol(‘Style’,’slider’);
lst = addlistener(sld,’Value’,’PostSet’,@(src,evt)disp(‘value changed’));
Changing the value of the slider directly from the Command Window ( sld.Value=0.5; ) causes the callback function to run, but moving the slider or pressing the arrows on its ends does nothing.
What am I doing wrong? I didn’t like how the normal callback implementation on the slider only updated once I stop dragging it, so I tried addlistener instead, but for some reason it just doesn’t respond at all. As a simple example, for the following code
sld = uicontrol(‘Style’,’slider’);
lst = addlistener(sld,’Value’,’PostSet’,@(src,evt)disp(‘value changed’));
Changing the value of the slider directly from the Command Window ( sld.Value=0.5; ) causes the callback function to run, but moving the slider or pressing the arrows on its ends does nothing.
What am I doing wrong? callback MATLAB Answers — New Questions
How can I get the Stockwell transform of an earthquake data in MATLAB?
Dear, I was wondering does MATLAB have any tool to calculate the Stockwell transform ? If it exists in MATLAB library, can you please provide me a script code so I can get S-tranform of an earthquake data. Thanks for your help. RegardsDear, I was wondering does MATLAB have any tool to calculate the Stockwell transform ? If it exists in MATLAB library, can you please provide me a script code so I can get S-tranform of an earthquake data. Thanks for your help. Regards Dear, I was wondering does MATLAB have any tool to calculate the Stockwell transform ? If it exists in MATLAB library, can you please provide me a script code so I can get S-tranform of an earthquake data. Thanks for your help. Regards matlab, transfer function, stockwell MATLAB Answers — New Questions
Excel Data preprocessing from a scattered one into an organised table
I have excel data that is pretty big (10000×63) and unorganised. I have attached the sample data file here (sample.xlsx).
This data is converted from a pdf to excel so there are a lot of issues. I will highlight some of them here.
Some key things to note about data
There are strings and numbers and I would like to keep them both organised.
After every 200-250 rows, the table header labels keep repeating which I would like to remove
Whenever the table header repeats, the columns shift left or right (sometimes upto 5 or 6 columns)
There is one column "Code" which has both strings(1,2) and numbers(2).
There are some cells where there is no data or "——".
There are some texts on the top and bottom of the table (legends etc) which I would like to remove.
I would like the data to look like this one big simple list (it took me 4 hours to make this). I would like to automate it as I have many excel files of similar dimensions(10000×63).
Additionally I would like to know if there’s a better way to organise this data other than matlab?
Thank you well in advance for your help. I am still learning matlab so any help would mean a lot!I have excel data that is pretty big (10000×63) and unorganised. I have attached the sample data file here (sample.xlsx).
This data is converted from a pdf to excel so there are a lot of issues. I will highlight some of them here.
Some key things to note about data
There are strings and numbers and I would like to keep them both organised.
After every 200-250 rows, the table header labels keep repeating which I would like to remove
Whenever the table header repeats, the columns shift left or right (sometimes upto 5 or 6 columns)
There is one column "Code" which has both strings(1,2) and numbers(2).
There are some cells where there is no data or "——".
There are some texts on the top and bottom of the table (legends etc) which I would like to remove.
I would like the data to look like this one big simple list (it took me 4 hours to make this). I would like to automate it as I have many excel files of similar dimensions(10000×63).
Additionally I would like to know if there’s a better way to organise this data other than matlab?
Thank you well in advance for your help. I am still learning matlab so any help would mean a lot! I have excel data that is pretty big (10000×63) and unorganised. I have attached the sample data file here (sample.xlsx).
This data is converted from a pdf to excel so there are a lot of issues. I will highlight some of them here.
Some key things to note about data
There are strings and numbers and I would like to keep them both organised.
After every 200-250 rows, the table header labels keep repeating which I would like to remove
Whenever the table header repeats, the columns shift left or right (sometimes upto 5 or 6 columns)
There is one column "Code" which has both strings(1,2) and numbers(2).
There are some cells where there is no data or "——".
There are some texts on the top and bottom of the table (legends etc) which I would like to remove.
I would like the data to look like this one big simple list (it took me 4 hours to make this). I would like to automate it as I have many excel files of similar dimensions(10000×63).
Additionally I would like to know if there’s a better way to organise this data other than matlab?
Thank you well in advance for your help. I am still learning matlab so any help would mean a lot! importing excel data, data import MATLAB Answers — New Questions
How to create a row vector upto a particular distance with the help of a variable?
taking n=4 i could add a vector of elements value 7 to a previously defined B.
but when i use second expression for n=4 , error occurs?
Anyone could help?taking n=4 i could add a vector of elements value 7 to a previously defined B.
but when i use second expression for n=4 , error occurs?
Anyone could help? taking n=4 i could add a vector of elements value 7 to a previously defined B.
but when i use second expression for n=4 , error occurs?
Anyone could help? add vector elements to a vector matrix MATLAB Answers — New Questions
Inconsistency reading .mov video files
I have some .mov video files that I need to process. I use the "read" function to read them after creating the video object
vid = VideoReader([pathname videoID]);
numFrames = vid.NumFrames;
for frame = 1:numFrames
temp_frame = read(vid,frame);
end
I just do some image processing to each of the frames (temp_frame) and save the results that I am interested in.
Everything works fine. However, if I run the same exact code in another computer, the intensity of each temp_frame is considerably different. For instance, if I run just that piece of code on computer1 (Windows 11 pro) the mean, max and min image intensity values are 0.9615, 1 and 0.7098 respectively, and in computer 2 (Windows 11 Home) the mean, max and min image intensity values are 0.9920, 1 and 0.7569.
Does anyone know the reason of this discrepancy and how can I solve it?
Thank you in advance.I have some .mov video files that I need to process. I use the "read" function to read them after creating the video object
vid = VideoReader([pathname videoID]);
numFrames = vid.NumFrames;
for frame = 1:numFrames
temp_frame = read(vid,frame);
end
I just do some image processing to each of the frames (temp_frame) and save the results that I am interested in.
Everything works fine. However, if I run the same exact code in another computer, the intensity of each temp_frame is considerably different. For instance, if I run just that piece of code on computer1 (Windows 11 pro) the mean, max and min image intensity values are 0.9615, 1 and 0.7098 respectively, and in computer 2 (Windows 11 Home) the mean, max and min image intensity values are 0.9920, 1 and 0.7569.
Does anyone know the reason of this discrepancy and how can I solve it?
Thank you in advance. I have some .mov video files that I need to process. I use the "read" function to read them after creating the video object
vid = VideoReader([pathname videoID]);
numFrames = vid.NumFrames;
for frame = 1:numFrames
temp_frame = read(vid,frame);
end
I just do some image processing to each of the frames (temp_frame) and save the results that I am interested in.
Everything works fine. However, if I run the same exact code in another computer, the intensity of each temp_frame is considerably different. For instance, if I run just that piece of code on computer1 (Windows 11 pro) the mean, max and min image intensity values are 0.9615, 1 and 0.7098 respectively, and in computer 2 (Windows 11 Home) the mean, max and min image intensity values are 0.9920, 1 and 0.7569.
Does anyone know the reason of this discrepancy and how can I solve it?
Thank you in advance. video processing, image processing, videoreader, read MATLAB Answers — New Questions
How to fix error 5201?
"Hello, I’m having an issue with installing MATLAB. It used to work fine on my computer, but one day it updated and I couldn’t open it. I restarted the computer, downloaded other versions, and I keep getting error 5201 constantly. What is the cause of this? How can I fix it?"Hello, I’m having an issue with installing MATLAB. It used to work fine on my computer, but one day it updated and I couldn’t open it. I restarted the computer, downloaded other versions, and I keep getting error 5201 constantly. What is the cause of this? How can I fix it? "Hello, I’m having an issue with installing MATLAB. It used to work fine on my computer, but one day it updated and I couldn’t open it. I restarted the computer, downloaded other versions, and I keep getting error 5201 constantly. What is the cause of this? How can I fix it? error 5201, installation MATLAB Answers — New Questions
Error 5201. Installation not associated with my account.
I have installed MatLab and associated my academic license but when I try to open it I get the message ‘Error 5201’. I have tried to solve it following the steps indicated in ‘Help’ – reinstall it, disable antivirus and firewall – but it doesn’t work. According to MathWorks there are no activations: the installation is not associated to my account. However I have the application on my computer and the folder with all the corresponding files including the license and executables.
I don’t know how to continue at this point.I have installed MatLab and associated my academic license but when I try to open it I get the message ‘Error 5201’. I have tried to solve it following the steps indicated in ‘Help’ – reinstall it, disable antivirus and firewall – but it doesn’t work. According to MathWorks there are no activations: the installation is not associated to my account. However I have the application on my computer and the folder with all the corresponding files including the license and executables.
I don’t know how to continue at this point. I have installed MatLab and associated my academic license but when I try to open it I get the message ‘Error 5201’. I have tried to solve it following the steps indicated in ‘Help’ – reinstall it, disable antivirus and firewall – but it doesn’t work. According to MathWorks there are no activations: the installation is not associated to my account. However I have the application on my computer and the folder with all the corresponding files including the license and executables.
I don’t know how to continue at this point. error 5201, activations, installation, licensing MATLAB Answers — New Questions
Figures are not saving as the correct size when put into a PDF
Please, I would appreciate any help as I have been stuck on this question for days. I have coded a loop that takes images from a folder and puts them in a 2×2 table and automatically numbers them. It creates a figure with the four images on it. It repeats this process until all the images have been used. Then it creates a PDF with all the figures saved, e.g. one figure of four images per page. My issue is, I need the figures to be in the centre of a landscape page, with white space margins around this. Currently, the images look fine on the figure display when you run the code, but when I open up the PDF, they take up the entire page and leave no margin space. I’ll insert two images of what I currently get, and what I need to produce. I would be so so appreciative of anyone that can help me please. Each image needs to be 10cm width by 7cm height on a landscape page in the final PDF.
Coding is not my strongest suit so I apologise if I have mistakenly used the wrong terminology. Thank you in advance.
Here’s the relevant parts of my code.
% Define the desired figure size in inches
figureWidth = 11.7; % Total width of the figure in inches
figureHeight = 8.3; % Total height of the figure in inches
% Define the desired image size in centimeters
imageWidth_cm = 10; % Width of each image in centimeters
imageHeight_cm = 7.5; % Height of each image in centimeters
% Convert image size from centimeters to inches
imageWidth_inch = imageWidth_cm / 2.54; % Convert cm to inches
imageHeight_inch = imageHeight_cm / 2.54; % Convert cm to inches
% Define the spacing between images (in inches)
horizontalSpacing = 0.5; % Spacing between images horizontally
verticalSpacing = 0.5; % Spacing between images vertically
% Calculate the total width and height required for the 2×2 grid
totalWidth = 2 * imageWidth_inch + horizontalSpacing;
totalHeight = 2 * imageHeight_inch + verticalSpacing;
% Calculate the left and bottom margins to center the grid
leftMargin = (figureWidth – totalWidth) / 2;
bottomMargin = (figureHeight – totalHeight) / 2;
% Initialize a cell array to store figure handles
figures = cell(numTables, 1);
% Calculate the position of the subplot
subplotX = leftMargin + mod(i – 1, 2) * (imageWidth_inch + horizontalSpacing);
subplotY = bottomMargin + floor((i – 1) / 2) * (imageHeight_inch + verticalSpacing);
% Create a subplot for each image
axes(‘Position’, [subplotX / figureWidth, subplotY / figureHeight, imageWidth_inch / figureWidth, imageHeight_inch / figureHeight]);
imshow(img);
axis off;
% Save the figure as a high-resolution image
outputFileName = fullfile(outputFolder, [‘Figure_’, num2str(tableIdx), ‘.png’]);
exportgraphics(fig, outputFileName, ‘Resolution’, 300);
outputPDF = fullfile(outputFolder, ‘output.pdf’); % Define the output PDF file
for i = 1:numTables
% Export the figure to the PDF
exportgraphics(figures{i}, outputPDF, ‘Resolution’, 300, ‘Append’, i > 1, ‘ContentType’, ‘vector’, ‘Padding’, 0.5);
endPlease, I would appreciate any help as I have been stuck on this question for days. I have coded a loop that takes images from a folder and puts them in a 2×2 table and automatically numbers them. It creates a figure with the four images on it. It repeats this process until all the images have been used. Then it creates a PDF with all the figures saved, e.g. one figure of four images per page. My issue is, I need the figures to be in the centre of a landscape page, with white space margins around this. Currently, the images look fine on the figure display when you run the code, but when I open up the PDF, they take up the entire page and leave no margin space. I’ll insert two images of what I currently get, and what I need to produce. I would be so so appreciative of anyone that can help me please. Each image needs to be 10cm width by 7cm height on a landscape page in the final PDF.
Coding is not my strongest suit so I apologise if I have mistakenly used the wrong terminology. Thank you in advance.
Here’s the relevant parts of my code.
% Define the desired figure size in inches
figureWidth = 11.7; % Total width of the figure in inches
figureHeight = 8.3; % Total height of the figure in inches
% Define the desired image size in centimeters
imageWidth_cm = 10; % Width of each image in centimeters
imageHeight_cm = 7.5; % Height of each image in centimeters
% Convert image size from centimeters to inches
imageWidth_inch = imageWidth_cm / 2.54; % Convert cm to inches
imageHeight_inch = imageHeight_cm / 2.54; % Convert cm to inches
% Define the spacing between images (in inches)
horizontalSpacing = 0.5; % Spacing between images horizontally
verticalSpacing = 0.5; % Spacing between images vertically
% Calculate the total width and height required for the 2×2 grid
totalWidth = 2 * imageWidth_inch + horizontalSpacing;
totalHeight = 2 * imageHeight_inch + verticalSpacing;
% Calculate the left and bottom margins to center the grid
leftMargin = (figureWidth – totalWidth) / 2;
bottomMargin = (figureHeight – totalHeight) / 2;
% Initialize a cell array to store figure handles
figures = cell(numTables, 1);
% Calculate the position of the subplot
subplotX = leftMargin + mod(i – 1, 2) * (imageWidth_inch + horizontalSpacing);
subplotY = bottomMargin + floor((i – 1) / 2) * (imageHeight_inch + verticalSpacing);
% Create a subplot for each image
axes(‘Position’, [subplotX / figureWidth, subplotY / figureHeight, imageWidth_inch / figureWidth, imageHeight_inch / figureHeight]);
imshow(img);
axis off;
% Save the figure as a high-resolution image
outputFileName = fullfile(outputFolder, [‘Figure_’, num2str(tableIdx), ‘.png’]);
exportgraphics(fig, outputFileName, ‘Resolution’, 300);
outputPDF = fullfile(outputFolder, ‘output.pdf’); % Define the output PDF file
for i = 1:numTables
% Export the figure to the PDF
exportgraphics(figures{i}, outputPDF, ‘Resolution’, 300, ‘Append’, i > 1, ‘ContentType’, ‘vector’, ‘Padding’, 0.5);
end Please, I would appreciate any help as I have been stuck on this question for days. I have coded a loop that takes images from a folder and puts them in a 2×2 table and automatically numbers them. It creates a figure with the four images on it. It repeats this process until all the images have been used. Then it creates a PDF with all the figures saved, e.g. one figure of four images per page. My issue is, I need the figures to be in the centre of a landscape page, with white space margins around this. Currently, the images look fine on the figure display when you run the code, but when I open up the PDF, they take up the entire page and leave no margin space. I’ll insert two images of what I currently get, and what I need to produce. I would be so so appreciative of anyone that can help me please. Each image needs to be 10cm width by 7cm height on a landscape page in the final PDF.
Coding is not my strongest suit so I apologise if I have mistakenly used the wrong terminology. Thank you in advance.
Here’s the relevant parts of my code.
% Define the desired figure size in inches
figureWidth = 11.7; % Total width of the figure in inches
figureHeight = 8.3; % Total height of the figure in inches
% Define the desired image size in centimeters
imageWidth_cm = 10; % Width of each image in centimeters
imageHeight_cm = 7.5; % Height of each image in centimeters
% Convert image size from centimeters to inches
imageWidth_inch = imageWidth_cm / 2.54; % Convert cm to inches
imageHeight_inch = imageHeight_cm / 2.54; % Convert cm to inches
% Define the spacing between images (in inches)
horizontalSpacing = 0.5; % Spacing between images horizontally
verticalSpacing = 0.5; % Spacing between images vertically
% Calculate the total width and height required for the 2×2 grid
totalWidth = 2 * imageWidth_inch + horizontalSpacing;
totalHeight = 2 * imageHeight_inch + verticalSpacing;
% Calculate the left and bottom margins to center the grid
leftMargin = (figureWidth – totalWidth) / 2;
bottomMargin = (figureHeight – totalHeight) / 2;
% Initialize a cell array to store figure handles
figures = cell(numTables, 1);
% Calculate the position of the subplot
subplotX = leftMargin + mod(i – 1, 2) * (imageWidth_inch + horizontalSpacing);
subplotY = bottomMargin + floor((i – 1) / 2) * (imageHeight_inch + verticalSpacing);
% Create a subplot for each image
axes(‘Position’, [subplotX / figureWidth, subplotY / figureHeight, imageWidth_inch / figureWidth, imageHeight_inch / figureHeight]);
imshow(img);
axis off;
% Save the figure as a high-resolution image
outputFileName = fullfile(outputFolder, [‘Figure_’, num2str(tableIdx), ‘.png’]);
exportgraphics(fig, outputFileName, ‘Resolution’, 300);
outputPDF = fullfile(outputFolder, ‘output.pdf’); % Define the output PDF file
for i = 1:numTables
% Export the figure to the PDF
exportgraphics(figures{i}, outputPDF, ‘Resolution’, 300, ‘Append’, i > 1, ‘ContentType’, ‘vector’, ‘Padding’, 0.5);
end pdf, size, image, figure, output, merge MATLAB Answers — New Questions
how can I switc between three systems of ODEs basing on the value of the second solution of each system, and repeat the cycle ?
I have three systems of differential equations, each systemt consists of ten equations, and the first system has initial conditions.
I want to automate the solution and switching between these systems where:
When the value of the second solution of the first system reaches a certain value (symbolised by T_b), the solution of the first system stops and the solution of the second system begins, whose initial conditions are the final conditions of the first system.
When the value of the second solution of the second system reaches a value less than T_b, the solution of the second system stops and the solution of the third system starts, whose initial conditions are the final conditions of the second system.
when finish this , repeat the cycle untill finishin the time spane (200 hours).I have three systems of differential equations, each systemt consists of ten equations, and the first system has initial conditions.
I want to automate the solution and switching between these systems where:
When the value of the second solution of the first system reaches a certain value (symbolised by T_b), the solution of the first system stops and the solution of the second system begins, whose initial conditions are the final conditions of the first system.
When the value of the second solution of the second system reaches a value less than T_b, the solution of the second system stops and the solution of the third system starts, whose initial conditions are the final conditions of the second system.
when finish this , repeat the cycle untill finishin the time spane (200 hours). I have three systems of differential equations, each systemt consists of ten equations, and the first system has initial conditions.
I want to automate the solution and switching between these systems where:
When the value of the second solution of the first system reaches a certain value (symbolised by T_b), the solution of the first system stops and the solution of the second system begins, whose initial conditions are the final conditions of the first system.
When the value of the second solution of the second system reaches a value less than T_b, the solution of the second system stops and the solution of the third system starts, whose initial conditions are the final conditions of the second system.
when finish this , repeat the cycle untill finishin the time spane (200 hours). switch, odes system MATLAB Answers — New Questions
Unable to Extract Numbers Using OCR Despite Performing Image Processing
I have images from a screen recording from which I am trying extract certain text and numbers.
I then crop the regions of interest (ROI) and proceed to resize the image from each ROI. Finally I apply various processing techniques such as filtering, adaptive histogram equalization, masking, binarization and morphological operations as shown below.
My code is shared as under
function [final_frame,point_cloud_block_values] = block_extractor_v10(img)
%% Define Region of Interest
a0 = 25;
for dd = 1:25
a_n(dd) = a0+45*(dd-1);
end
roi_matrix = [360.*ones(25,1),a_n’,67.*ones(25,1),32.*ones(25,1)];
roi3 = [111.51,1099.51,172.98,43.98]; %Final frame name
point_cloud_block_values = zeros(25,1);
for gg = 1:25
I2 = imcrop(img,roi_matrix(gg,:));
I3 = imresize(I2,[33*63,68*68]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
I3 = imresize(I2,[33*70,68*80]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||temp>12000
I3_average1 = rgb2gray(I3);
mask = I3_average1 < 60;
mask = imclose(mask, true(9, 5));
txt1 = ocr(mask,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||size(temp,1)>1
I3_average1 = rgb2gray(I3);
I3_filt = medfilt2(I3_average1);
I3_filt = adapthisteq(I3_filt);
se = strel(‘disk’,1);
I3_filt = imopen(I3_filt,se);
I3_filt = imbinarize(I3_filt);
txt1 = ocr(I3_filt,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
point_cloud_block_values(gg) = temp;
end
txt3 = ocr(img,roi3,CharacterSet="_aeFmr0123456789",LayoutAnalysis="line");
if length(point_cloud_block_values) ~=25
error(‘The length of each block must be 25’)
end
final_frame = txt3.Words;
final_frame = char(final_frame);
end
However, I am unable to get 100% accuracy in text detection as there are several instances where the text is incorrectly identified by OCR as shown below.
I have uploaded the entire image database on my my google drive. Please adviseI have images from a screen recording from which I am trying extract certain text and numbers.
I then crop the regions of interest (ROI) and proceed to resize the image from each ROI. Finally I apply various processing techniques such as filtering, adaptive histogram equalization, masking, binarization and morphological operations as shown below.
My code is shared as under
function [final_frame,point_cloud_block_values] = block_extractor_v10(img)
%% Define Region of Interest
a0 = 25;
for dd = 1:25
a_n(dd) = a0+45*(dd-1);
end
roi_matrix = [360.*ones(25,1),a_n’,67.*ones(25,1),32.*ones(25,1)];
roi3 = [111.51,1099.51,172.98,43.98]; %Final frame name
point_cloud_block_values = zeros(25,1);
for gg = 1:25
I2 = imcrop(img,roi_matrix(gg,:));
I3 = imresize(I2,[33*63,68*68]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
I3 = imresize(I2,[33*70,68*80]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||temp>12000
I3_average1 = rgb2gray(I3);
mask = I3_average1 < 60;
mask = imclose(mask, true(9, 5));
txt1 = ocr(mask,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||size(temp,1)>1
I3_average1 = rgb2gray(I3);
I3_filt = medfilt2(I3_average1);
I3_filt = adapthisteq(I3_filt);
se = strel(‘disk’,1);
I3_filt = imopen(I3_filt,se);
I3_filt = imbinarize(I3_filt);
txt1 = ocr(I3_filt,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
point_cloud_block_values(gg) = temp;
end
txt3 = ocr(img,roi3,CharacterSet="_aeFmr0123456789",LayoutAnalysis="line");
if length(point_cloud_block_values) ~=25
error(‘The length of each block must be 25’)
end
final_frame = txt3.Words;
final_frame = char(final_frame);
end
However, I am unable to get 100% accuracy in text detection as there are several instances where the text is incorrectly identified by OCR as shown below.
I have uploaded the entire image database on my my google drive. Please advise I have images from a screen recording from which I am trying extract certain text and numbers.
I then crop the regions of interest (ROI) and proceed to resize the image from each ROI. Finally I apply various processing techniques such as filtering, adaptive histogram equalization, masking, binarization and morphological operations as shown below.
My code is shared as under
function [final_frame,point_cloud_block_values] = block_extractor_v10(img)
%% Define Region of Interest
a0 = 25;
for dd = 1:25
a_n(dd) = a0+45*(dd-1);
end
roi_matrix = [360.*ones(25,1),a_n’,67.*ones(25,1),32.*ones(25,1)];
roi3 = [111.51,1099.51,172.98,43.98]; %Final frame name
point_cloud_block_values = zeros(25,1);
for gg = 1:25
I2 = imcrop(img,roi_matrix(gg,:));
I3 = imresize(I2,[33*63,68*68]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)||txt1.TextLineConfidences <0.5
I3 = imresize(I2,[33*70,68*80]);
txt1 = ocr(I3,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||temp>12000
I3_average1 = rgb2gray(I3);
mask = I3_average1 < 60;
mask = imclose(mask, true(9, 5));
txt1 = ocr(mask,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
if isempty(temp)
txt1 = ocr(I2,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
end
if isempty(temp)||size(temp,1)>1
I3_average1 = rgb2gray(I3);
I3_filt = medfilt2(I3_average1);
I3_filt = adapthisteq(I3_filt);
se = strel(‘disk’,1);
I3_filt = imopen(I3_filt,se);
I3_filt = imbinarize(I3_filt);
txt1 = ocr(I3_filt,CharacterSet="0123456789",LayoutAnalysis="line");
temp = str2double(txt1.Words);
end
point_cloud_block_values(gg) = temp;
end
txt3 = ocr(img,roi3,CharacterSet="_aeFmr0123456789",LayoutAnalysis="line");
if length(point_cloud_block_values) ~=25
error(‘The length of each block must be 25’)
end
final_frame = txt3.Words;
final_frame = char(final_frame);
end
However, I am unable to get 100% accuracy in text detection as there are several instances where the text is incorrectly identified by OCR as shown below.
I have uploaded the entire image database on my my google drive. Please advise ocr, image processing, textscan MATLAB Answers — New Questions
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
Hey guys
I’ve written some code to compute cost function at various theta, as follows:
h = X * theta;
J = [1/(2*m)] * sum[(h-y).^2];
All variables have been defined. Upon running the code above, I’m getting the following error message:
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
I have no experience with Matlab, so any help would be appreciated!
ThanksHey guys
I’ve written some code to compute cost function at various theta, as follows:
h = X * theta;
J = [1/(2*m)] * sum[(h-y).^2];
All variables have been defined. Upon running the code above, I’m getting the following error message:
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
I have no experience with Matlab, so any help would be appreciated!
Thanks Hey guys
I’ve written some code to compute cost function at various theta, as follows:
h = X * theta;
J = [1/(2*m)] * sum[(h-y).^2];
All variables have been defined. Upon running the code above, I’m getting the following error message:
Error: Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters.
I have no experience with Matlab, so any help would be appreciated!
Thanks error MATLAB Answers — New Questions
I have an excel file with 5 columns X1/X2/X3/X4/X5 how to I plot 4 plots (X1,X2;X1,X3;X1;X4;X1;X5) on the same figure using the subplot command.
Do I use xlsreadDo I use xlsread Do I use xlsread subplot MATLAB Answers — New Questions
Design of smart meters to curb electricity issues
Working on designing a smart meter to curb electricity connections and power issuesWorking on designing a smart meter to curb electricity connections and power issues Working on designing a smart meter to curb electricity connections and power issues electric_motor_control MATLAB Answers — New Questions