No output from Matlab Table
1 回表示 (過去 30 日間)
古いコメントを表示
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
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
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
2023 年 2 月 16 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!