Hello, this is the matlab message: "Undefined operator '*' for input arguments of type 'LinearModel'"

조회 수: 4 (최근 30일)
load ('DATI_PAZ1');
LV_1=LV;
lat_1=lat;
sept_1=sept;
time_1=time;
load ('DATI_PAZ2');
LV_2=LV;
lat_2=lat;
ant_2=ant;
time_2=time;
figure
plot(time_1,LV_1,'k')
hold on
plot(time_1,lat_1,'b')
hold on
plot(time_1,sept_1,'r')
grid on
xlabel('time [s]'),ylabel('colpi/(s*voxel)')
title('Conc. FDG - CASO I')
legend('ventr.sx','laterale','setto')
figure
plot(time_2,LV_2,'k')
hold on
plot(time_2,lat_2,'b')
hold on
plot(time_2,ant_2,'r')
grid on
xlabel('time [s]'),ylabel('colpi/(s*voxel)')
title('Conc. FDG - CASO II')
legend('ventr.sx','laterale','anteriore')
y_lat_1=lat_1./LV_1;
y_sept_1=sept_1./LV_1;
x_1=cumtrapz(time_1,LV_1)./LV_1;
figure
subplot(1,2,1)
plot(x_1,y_lat_1,'*b')
hold on
plot(x_1,y_sept_1,'*r')
title('Patlak graph - CASO I')
F_sept_1=fitlm(x_1(18:24,1),y_sept_1(18:24,1),'poly1');
hold on
plot(F_sept_1)
F_lat_1=fitlm(x_1(18:24,1),y_lat_1(18:24,1),'poly1');
hold on
plot(F_lat_1)
legend('parete laterale','setto')
xlabel('trapz( C_p(t) dt)/C_p(t) [s]'),ylabel('C_t(t)/C_p(t) [adimensionale]')
m_setto_1=F_sept_1;
m_laterale_1=F_lat_1;
LC = 0.67;
Cp = 100/100;%mg/cm^3 passaggio da dl a cm^3
rho=1.08;%g/cm^3
R_setto_1=m_setto_1*60*Cp/LC*(1/rho); %error
R_laterale_1=m_laterale_1*60*Cp/LC*(1/rho); %error

답변 (1개)

Sameer
Sameer 2024년 9월 13일
편집: Sameer 2024년 9월 13일
Hi Gabriele
The error message you're encountering, "Undefined operator '*' for input arguments of type 'LinearModel'," indicates that you are trying to use the multiplication operator * with a LinearModel object, which is not directly supported in MATLAB.
The "fitlm" function returns a LinearModel object, which contains information about the fitted model, but it is not a numeric value that can be directly multiplied.
To resolve this, extract the slope (coefficient) from the LinearModel object before performing the multiplication. Here's how you can modify the code:
% Assuming F_sept_1 and F_lat_1 are LinearModel objects from fitlm
m_setto_1 = F_sept_1.Coefficients.Estimate(2); % Extract the slope (second element)
m_laterale_1 = F_lat_1.Coefficients.Estimate(2); % Extract the slope (second element)
LC = 0.67;
Cp = 100/100; % mg/cm^3 conversion from dl to cm^3
rho = 1.08; % g/cm^3
% Now you can perform the multiplication
R_setto_1 = m_setto_1 * 60 * Cp / LC * (1 / rho);
R_laterale_1 = m_laterale_1 * 60 * Cp / LC * (1 / rho);
Please refer to the below MathWorks documentation link:
Hope this helps!

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by