No output from Matlab Table

1 次查看(过去 30 天)
Frank Lehmann
Frank Lehmann 2023-2-16
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 个评论
Matt J
Matt J 2023-2-16
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 2023-2-16
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.

请先登录,再进行评论。

回答(1 个)

Oguz Kaan Hancioglu
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.

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by