我可以从终端执行以下操作:
matlab -nojvm < span.m
这样可以正常工作并产生所需的输出。
但是,在同一目录中,如果我写一个bash脚本:
#!/bin/bash
matlab -nojvm < span.m
执行时出现以下错误:
wallShearStresswallsconstant=importdata("wallShearStress_wallBottom.raw");
|
Error: The input character is not valid in MATLAB statements or expressions.
Undefined function 'wallShearStresswallsconstant' for input arguments of type
'double'.
请让我知道我做错了什么。
matlab脚本如下所示,它读取一个包含6列和45288行(所有数字)的文件(wallShearStress_wallBottom.raw),用于测试目的是什么数量。
clear all
clc
wallShearStresswallsconstant=importdata("wallShearStress_wallBottom.raw");
ly=110;%64; %nz
lx=407;%239;%nx
ShearStress=zeros(lx,5);
%Uinf=15.894579;
Uinf=16.77;
i=1;
j=1;
k=1;
while i<lx+1
while j<ly+1
ShearStress(i,1)=wallShearStresswallsconstant(k,1);
ShearStress(i,2)=wallShearStresswallsconstant(k,2);
ShearStress(i,3)=wallShearStresswallsconstant(k,3);
if wallShearStresswallsconstant(k,4) < 0
ShearStress(i,4)=ShearStress(i,4)+1;
else
ShearStress(i,5)=ShearStress(i,5)-1;
end
j=j+1;
k=k+1;
end
j=1;
i=i+1;
end
SS = ShearStress;
SS(:,5) = SS(:,4)-SS(:,5);
SS(:,4) = SS(:,4)./SS(:,5);
plot(SS(:,1),SS(:,4))
SS = SS';
fileID = fopen('new.txt', 'w');
fprintf(fileID,'%f %f %f %f %f\n',SS);
答案 0 :(得分:0)
请改用以下代码:
importdata('wallShearStress_wallBottom.raw');
执行matlab脚本文件的常用bash命令如下:
matlab -nodisplay -nojvm -nosplash -nodesktop -r \
"try, span, catch, exit(1), end, exit(0);"
其中span
是您的.m
文件名。