No output from Matlab Table

1 visualización (últimos 30 días)
Frank Lehmann
Frank Lehmann el 16 de Feb. de 2023
Respondida: Oguz Kaan Hancioglu el 16 de Feb. de 2023
Hi can anyone advise on why lines 21, 22 are not producing an output to the workspace? The table is produced but cannot for somw reason produc Q or T
function [] = TOTAL_HV_CONDUCTOR_DETAILS(cableVoltage,coreType,cableInstallation,cableSize)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
if strcmp(cableVoltage,'3.8/6.6kV') && strcmp(coreType,'3X1C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3x1C','Range','B11:AU28','VariableNamingRule','preserve','ReadRowNames',true)
elseif strcmp(cableVoltage,'6.35/11kV') && strcmp(coreType,'3X1C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3x1C','Range','B40:AU57','VariableNamingRule','preserve','ReadRowNames',true)
elseif strcmp(cableVoltage,'12.7/22kV') && strcmp(coreType,'3X1C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3x1C','Range','B69:AU84','VariableNamingRule','preserve','ReadRowNames',true)
elseif strcmp(cableVoltage,'19/33kV') && strcmp(coreType,'3X1C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3x1C','Range','B96:AU110','VariableNamingRule','preserve','ReadRowNames',true)
if strcmp(cableVoltage,'3.8/6.6kV') && strcmp(coreType,'3C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3C','Range','B11:AJ24','VariableNamingRule','preserve','ReadRowNames',true)
elseif strcmp(cableVoltage,'6.35/11kV') && strcmp(coreType,'3C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3C','Range','B36:AJ49','VariableNamingRule','preserve','ReadRowNames',true)
elseif strcmp(cableVoltage,'12.7/22kV') && strcmp(coreType,'3C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3x1C','Range','B61:AJ72','VariableNamingRule','preserve','ReadRowNames',true)
elseif strcmp(cableVoltage,'19/33kV') && strcmp(coreType,'3C')
A=readtable('HV_Cable_Parameters.xlsx','Sheet','3C','Range','B84:AJ94','VariableNamingRule','preserve','ReadRowNames',true)
end
Q=summary(A)
T=A(cableSize,cableInstallation)
  2 comentarios
Matt J
Matt J el 16 de Feb. de 2023
I would suggest running the code for us here online (not on your computer) so that we can see the result.
Walter Roberson
Walter Roberson el 16 de Feb. de 2023
By the way, have you consider parameterizing your code?
core_3X1C_params = {
'3.8/6.6Kv', 'B11:AY27'
'6.35/11kV', 'B40:AU57'
'12.7/22kV', 'B69:AU84'
'19/33kV', 'B96:AU110'}
core_3C_params = {
'3.8/6.6Kv', 'B11:AJ24'
'6.35/11kV', 'B40:AJ49'
'12.7/22kV', 'B69:AJ72'
'19/33kV', 'B96:AJ94'}
ismember() against the first column to find the Range information in the second column. The sheet name is the same as the coreType.

Iniciar sesión para comentar.

Respuestas (1)

Oguz Kaan Hancioglu
Oguz Kaan Hancioglu el 16 de Feb. de 2023
You are creating Q and T in the function. Function workspace is different than base workspace. Thats why Q and T is not seen in the base workspace.To do that,
  • You can add Q and T as a output of your function. When you call you need to assign new wariables.
function [Q,T] = TOTAL_HV_CONDUCTOR_DETAILS(cableVoltage,coreType,cableInstallation,cableSize)
  • You can use assignin function in order to save variable to workspace in different scopes.
assignin('base','Q',Q);
assignin('base','T',T);
I prefer to use the first one. The scope of each function should be separated from each other even the base workspace. You can use either.

Categorías

Más información sobre Environment and Settings en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by